39#ifndef INCLUDE_NLOHMANN_JSON_HPP_
40#define INCLUDE_NLOHMANN_JSON_HPP_
42#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
43#if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
44#if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 10 || NLOHMANN_JSON_VERSION_PATCH != 5
45#warning "Already included a different version of the library!"
50#define NLOHMANN_JSON_VERSION_MAJOR 3
51#define NLOHMANN_JSON_VERSION_MINOR 10
52#define NLOHMANN_JSON_VERSION_PATCH 5
57#include <initializer_list>
79#include <forward_list>
85#include <unordered_map>
125#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
126#if defined(JSON_HEDLEY_VERSION)
127#undef JSON_HEDLEY_VERSION
129#define JSON_HEDLEY_VERSION 15
131#if defined(JSON_HEDLEY_STRINGIFY_EX)
132#undef JSON_HEDLEY_STRINGIFY_EX
134#define JSON_HEDLEY_STRINGIFY_EX(x) #x
136#if defined(JSON_HEDLEY_STRINGIFY)
137#undef JSON_HEDLEY_STRINGIFY
139#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
141#if defined(JSON_HEDLEY_CONCAT_EX)
142#undef JSON_HEDLEY_CONCAT_EX
144#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
146#if defined(JSON_HEDLEY_CONCAT)
147#undef JSON_HEDLEY_CONCAT
149#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
151#if defined(JSON_HEDLEY_CONCAT3_EX)
152#undef JSON_HEDLEY_CONCAT3_EX
154#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
156#if defined(JSON_HEDLEY_CONCAT3)
157#undef JSON_HEDLEY_CONCAT3
159#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
161#if defined(JSON_HEDLEY_VERSION_ENCODE)
162#undef JSON_HEDLEY_VERSION_ENCODE
164#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
166#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
167#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
169#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
171#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
172#undef JSON_HEDLEY_VERSION_DECODE_MINOR
174#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
176#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
177#undef JSON_HEDLEY_VERSION_DECODE_REVISION
179#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
181#if defined(JSON_HEDLEY_GNUC_VERSION)
182#undef JSON_HEDLEY_GNUC_VERSION
184#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
185#define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
186#elif defined(__GNUC__)
187#define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
190#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
191#undef JSON_HEDLEY_GNUC_VERSION_CHECK
193#if defined(JSON_HEDLEY_GNUC_VERSION)
194#define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
196#define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
199#if defined(JSON_HEDLEY_MSVC_VERSION)
200#undef JSON_HEDLEY_MSVC_VERSION
202#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
203#define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
204#elif defined(_MSC_FULL_VER) && !defined(__ICL)
205#define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
206#elif defined(_MSC_VER) && !defined(__ICL)
207#define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
210#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
211#undef JSON_HEDLEY_MSVC_VERSION_CHECK
213#if !defined(JSON_HEDLEY_MSVC_VERSION)
214#define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
215#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
216#define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
217#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
218#define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
220#define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
223#if defined(JSON_HEDLEY_INTEL_VERSION)
224#undef JSON_HEDLEY_INTEL_VERSION
226#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
227#define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
228#elif defined(__INTEL_COMPILER) && !defined(__ICL)
229#define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
232#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
233#undef JSON_HEDLEY_INTEL_VERSION_CHECK
235#if defined(JSON_HEDLEY_INTEL_VERSION)
236#define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
238#define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
241#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
242#undef JSON_HEDLEY_INTEL_CL_VERSION
244#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
245#define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
248#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
249#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
251#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
252#define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
254#define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
257#if defined(JSON_HEDLEY_PGI_VERSION)
258#undef JSON_HEDLEY_PGI_VERSION
260#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
261#define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
264#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
265#undef JSON_HEDLEY_PGI_VERSION_CHECK
267#if defined(JSON_HEDLEY_PGI_VERSION)
268#define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
270#define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
273#if defined(JSON_HEDLEY_SUNPRO_VERSION)
274#undef JSON_HEDLEY_SUNPRO_VERSION
276#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
277#define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
278#elif defined(__SUNPRO_C)
279#define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
280#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
281#define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
282#elif defined(__SUNPRO_CC)
283#define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
286#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
287#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
289#if defined(JSON_HEDLEY_SUNPRO_VERSION)
290#define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
292#define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
295#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
296#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
298#if defined(__EMSCRIPTEN__)
299#define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
302#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
303#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
305#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
306#define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
308#define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
311#if defined(JSON_HEDLEY_ARM_VERSION)
312#undef JSON_HEDLEY_ARM_VERSION
314#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
315#define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
316#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
317#define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
320#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
321#undef JSON_HEDLEY_ARM_VERSION_CHECK
323#if defined(JSON_HEDLEY_ARM_VERSION)
324#define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
326#define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
329#if defined(JSON_HEDLEY_IBM_VERSION)
330#undef JSON_HEDLEY_IBM_VERSION
332#if defined(__ibmxl__)
333#define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
334#elif defined(__xlC__) && defined(__xlC_ver__)
335#define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
336#elif defined(__xlC__)
337#define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
340#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
341#undef JSON_HEDLEY_IBM_VERSION_CHECK
343#if defined(JSON_HEDLEY_IBM_VERSION)
344#define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
346#define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
349#if defined(JSON_HEDLEY_TI_VERSION)
350#undef JSON_HEDLEY_TI_VERSION
353 defined(__TI_COMPILER_VERSION__) && \
355 defined(__TMS470__) || defined(__TI_ARM__) || \
356 defined(__MSP430__) || \
357 defined(__TMS320C2000__) \
359#if (__TI_COMPILER_VERSION__ >= 16000000)
360#define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
364#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
365#undef JSON_HEDLEY_TI_VERSION_CHECK
367#if defined(JSON_HEDLEY_TI_VERSION)
368#define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
370#define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
373#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
374#undef JSON_HEDLEY_TI_CL2000_VERSION
376#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
377#define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
380#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
381#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
383#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
384#define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
386#define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
389#if defined(JSON_HEDLEY_TI_CL430_VERSION)
390#undef JSON_HEDLEY_TI_CL430_VERSION
392#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
393#define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
396#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
397#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
399#if defined(JSON_HEDLEY_TI_CL430_VERSION)
400#define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
402#define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
405#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
406#undef JSON_HEDLEY_TI_ARMCL_VERSION
408#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
409#define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
412#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
413#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
415#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
416#define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
418#define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
421#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
422#undef JSON_HEDLEY_TI_CL6X_VERSION
424#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
425#define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
428#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
429#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
431#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
432#define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
434#define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
437#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
438#undef JSON_HEDLEY_TI_CL7X_VERSION
440#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
441#define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
444#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
445#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
447#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
448#define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
450#define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
453#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
454#undef JSON_HEDLEY_TI_CLPRU_VERSION
456#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
457#define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
460#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
461#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
463#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
464#define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
466#define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
469#if defined(JSON_HEDLEY_CRAY_VERSION)
470#undef JSON_HEDLEY_CRAY_VERSION
473#if defined(_RELEASE_PATCHLEVEL)
474#define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
476#define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
480#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
481#undef JSON_HEDLEY_CRAY_VERSION_CHECK
483#if defined(JSON_HEDLEY_CRAY_VERSION)
484#define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
486#define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
489#if defined(JSON_HEDLEY_IAR_VERSION)
490#undef JSON_HEDLEY_IAR_VERSION
492#if defined(__IAR_SYSTEMS_ICC__)
494#define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
496#define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
500#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
501#undef JSON_HEDLEY_IAR_VERSION_CHECK
503#if defined(JSON_HEDLEY_IAR_VERSION)
504#define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
506#define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
509#if defined(JSON_HEDLEY_TINYC_VERSION)
510#undef JSON_HEDLEY_TINYC_VERSION
512#if defined(__TINYC__)
513#define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
516#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
517#undef JSON_HEDLEY_TINYC_VERSION_CHECK
519#if defined(JSON_HEDLEY_TINYC_VERSION)
520#define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
522#define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
525#if defined(JSON_HEDLEY_DMC_VERSION)
526#undef JSON_HEDLEY_DMC_VERSION
529#define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
532#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
533#undef JSON_HEDLEY_DMC_VERSION_CHECK
535#if defined(JSON_HEDLEY_DMC_VERSION)
536#define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
538#define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
541#if defined(JSON_HEDLEY_COMPCERT_VERSION)
542#undef JSON_HEDLEY_COMPCERT_VERSION
544#if defined(__COMPCERT_VERSION__)
545#define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
548#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
549#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
551#if defined(JSON_HEDLEY_COMPCERT_VERSION)
552#define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
554#define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
557#if defined(JSON_HEDLEY_PELLES_VERSION)
558#undef JSON_HEDLEY_PELLES_VERSION
561#define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
564#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
565#undef JSON_HEDLEY_PELLES_VERSION_CHECK
567#if defined(JSON_HEDLEY_PELLES_VERSION)
568#define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
570#define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
573#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
574#undef JSON_HEDLEY_MCST_LCC_VERSION
576#if defined(__LCC__) && defined(__LCC_MINOR__)
577#define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
580#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
581#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
583#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
584#define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
586#define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
589#if defined(JSON_HEDLEY_GCC_VERSION)
590#undef JSON_HEDLEY_GCC_VERSION
593 defined(JSON_HEDLEY_GNUC_VERSION) && \
594 !defined(__clang__) && \
595 !defined(JSON_HEDLEY_INTEL_VERSION) && \
596 !defined(JSON_HEDLEY_PGI_VERSION) && \
597 !defined(JSON_HEDLEY_ARM_VERSION) && \
598 !defined(JSON_HEDLEY_CRAY_VERSION) && \
599 !defined(JSON_HEDLEY_TI_VERSION) && \
600 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
601 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
602 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
603 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
604 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
605 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
606 !defined(__COMPCERT__) && \
607 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
608#define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
611#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
612#undef JSON_HEDLEY_GCC_VERSION_CHECK
614#if defined(JSON_HEDLEY_GCC_VERSION)
615#define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
617#define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
620#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
621#undef JSON_HEDLEY_HAS_ATTRIBUTE
624 defined(__has_attribute) && \
626 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
628# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
630# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
633#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
634#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
636#if defined(__has_attribute)
637#define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
639#define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
642#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
643#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
645#if defined(__has_attribute)
646#define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
648#define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
651#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
652#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
655 defined(__has_cpp_attribute) && \
656 defined(__cplusplus) && \
657 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
658#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
660#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
663#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
664#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
666#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
667#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
669 !defined(JSON_HEDLEY_PGI_VERSION) && \
670 !defined(JSON_HEDLEY_IAR_VERSION) && \
671 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
672 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
673#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
675#define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
678#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
679#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
681#if defined(__has_cpp_attribute) && defined(__cplusplus)
682#define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
684#define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
687#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
688#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
690#if defined(__has_cpp_attribute) && defined(__cplusplus)
691#define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
693#define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
696#if defined(JSON_HEDLEY_HAS_BUILTIN)
697#undef JSON_HEDLEY_HAS_BUILTIN
699#if defined(__has_builtin)
700#define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
702#define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
705#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
706#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
708#if defined(__has_builtin)
709#define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
711#define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
714#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
715#undef JSON_HEDLEY_GCC_HAS_BUILTIN
717#if defined(__has_builtin)
718#define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
720#define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
723#if defined(JSON_HEDLEY_HAS_FEATURE)
724#undef JSON_HEDLEY_HAS_FEATURE
726#if defined(__has_feature)
727#define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
729#define JSON_HEDLEY_HAS_FEATURE(feature) (0)
732#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
733#undef JSON_HEDLEY_GNUC_HAS_FEATURE
735#if defined(__has_feature)
736#define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
738#define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
741#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
742#undef JSON_HEDLEY_GCC_HAS_FEATURE
744#if defined(__has_feature)
745#define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
747#define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
750#if defined(JSON_HEDLEY_HAS_EXTENSION)
751#undef JSON_HEDLEY_HAS_EXTENSION
753#if defined(__has_extension)
754#define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
756#define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
759#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
760#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
762#if defined(__has_extension)
763#define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
765#define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
768#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
769#undef JSON_HEDLEY_GCC_HAS_EXTENSION
771#if defined(__has_extension)
772#define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
774#define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
777#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
778#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
780#if defined(__has_declspec_attribute)
781#define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
783#define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
786#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
787#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
789#if defined(__has_declspec_attribute)
790#define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
792#define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
795#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
796#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
798#if defined(__has_declspec_attribute)
799#define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
801#define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
804#if defined(JSON_HEDLEY_HAS_WARNING)
805#undef JSON_HEDLEY_HAS_WARNING
807#if defined(__has_warning)
808#define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
810#define JSON_HEDLEY_HAS_WARNING(warning) (0)
813#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
814#undef JSON_HEDLEY_GNUC_HAS_WARNING
816#if defined(__has_warning)
817#define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
819#define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
822#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
823#undef JSON_HEDLEY_GCC_HAS_WARNING
825#if defined(__has_warning)
826#define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
828#define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
832 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
833 defined(__clang__) || \
834 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
835 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
836 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
837 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
838 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
839 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
840 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
841 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
842 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
843 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
844 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
845 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
846 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
847 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
848 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
849 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
850#define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
851#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
852#define JSON_HEDLEY_PRAGMA(value) __pragma(value)
854#define JSON_HEDLEY_PRAGMA(value)
857#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
858#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
860#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
861#undef JSON_HEDLEY_DIAGNOSTIC_POP
863#if defined(__clang__)
864#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
865#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
866#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
867#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
868#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
869#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
870#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
871#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
873 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
874 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
875#define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
876#define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
877#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
878#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
879#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
881 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
882 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
883 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
884 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
885 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
886 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
887#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
888#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
889#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
890#define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
891#define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
893#define JSON_HEDLEY_DIAGNOSTIC_PUSH
894#define JSON_HEDLEY_DIAGNOSTIC_POP
899#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
900#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
902#if defined(__cplusplus)
903# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
904# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
905# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
906# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
907 JSON_HEDLEY_DIAGNOSTIC_PUSH \
908 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
909 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
910 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
912 JSON_HEDLEY_DIAGNOSTIC_POP
914# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
915 JSON_HEDLEY_DIAGNOSTIC_PUSH \
916 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
917 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
919 JSON_HEDLEY_DIAGNOSTIC_POP
922# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
923 JSON_HEDLEY_DIAGNOSTIC_PUSH \
924 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
926 JSON_HEDLEY_DIAGNOSTIC_POP
930#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
931#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
934#if defined(JSON_HEDLEY_CONST_CAST)
935#undef JSON_HEDLEY_CONST_CAST
937#if defined(__cplusplus)
938# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
940 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
941 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
942 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
943# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
944 JSON_HEDLEY_DIAGNOSTIC_PUSH \
945 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
947 JSON_HEDLEY_DIAGNOSTIC_POP \
950# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
953#if defined(JSON_HEDLEY_REINTERPRET_CAST)
954#undef JSON_HEDLEY_REINTERPRET_CAST
956#if defined(__cplusplus)
957#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
959#define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
962#if defined(JSON_HEDLEY_STATIC_CAST)
963#undef JSON_HEDLEY_STATIC_CAST
965#if defined(__cplusplus)
966#define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
968#define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
971#if defined(JSON_HEDLEY_CPP_CAST)
972#undef JSON_HEDLEY_CPP_CAST
974#if defined(__cplusplus)
975# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
976# define JSON_HEDLEY_CPP_CAST(T, expr) \
977 JSON_HEDLEY_DIAGNOSTIC_PUSH \
978 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
980 JSON_HEDLEY_DIAGNOSTIC_POP
981# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
982# define JSON_HEDLEY_CPP_CAST(T, expr) \
983 JSON_HEDLEY_DIAGNOSTIC_PUSH \
984 _Pragma("diag_suppress=Pe137") \
985 JSON_HEDLEY_DIAGNOSTIC_POP
987# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
990# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
993#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
994#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
996#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
997#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
998#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
999#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1000#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1001#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1002#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1003#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1004#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1005#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1006#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1007#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1008#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1009#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1010#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1011#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1013 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1014 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1015 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1016 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1017 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1018 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1019 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1020 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1021 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1022 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1023 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1024#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1025#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1026#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1027#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1028#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1029#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1030#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1031#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1032#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1034#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1037#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1038#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1040#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1041#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1042#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1043#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1044#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1045#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1046#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1047#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1048#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1049#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1050#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1051#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1053 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1054 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1055 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1056 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1057#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1058#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1059#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1060#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1061#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1062#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1063#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1065#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1068#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1069#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1071#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1072#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1073#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1074#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1075#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1076#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1077#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1078#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1079#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1080#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1081#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1082#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1083#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1084#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1085#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1086#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1088 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1089 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1090 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1091#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1092#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1093#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1094#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1095#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1097#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1100#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1101#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1103#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1104#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1105#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1106#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1107#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1108#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1110#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1113#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1114#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1116#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1117#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1118#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1119#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1120#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1121#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1122#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1123#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1125#define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1128#if defined(JSON_HEDLEY_DEPRECATED)
1129#undef JSON_HEDLEY_DEPRECATED
1131#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1132#undef JSON_HEDLEY_DEPRECATED_FOR
1135 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1136 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1137#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1138#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1140 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1141 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1142 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1143 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1144 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1145 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1146 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1147 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1148 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1149 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1150 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1151 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1152#define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1153#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1154#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1155#define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1156#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1158 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1159 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1160 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1161 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1162 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1163 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1164 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1165 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1166 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1167 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1168 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1169 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1170 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1171 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1172 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1173 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1174#define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1175#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1177 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1178 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1179 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1180#define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1181#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1182#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1183#define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1184#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1186#define JSON_HEDLEY_DEPRECATED(since)
1187#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1190#if defined(JSON_HEDLEY_UNAVAILABLE)
1191#undef JSON_HEDLEY_UNAVAILABLE
1194 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1195 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1196 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1197 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1198#define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1200#define JSON_HEDLEY_UNAVAILABLE(available_since)
1203#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1204#undef JSON_HEDLEY_WARN_UNUSED_RESULT
1206#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1207#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1210 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1211 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1212 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1213 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1214 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1215 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1216 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1217 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1218 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1219 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1220 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1221 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1222 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1223 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1224 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1225 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1226 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1227#define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1228#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1229#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1230#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1231#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1232#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1233#define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1234#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1235#elif defined(_Check_return_)
1236#define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1237#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1239#define JSON_HEDLEY_WARN_UNUSED_RESULT
1240#define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1243#if defined(JSON_HEDLEY_SENTINEL)
1244#undef JSON_HEDLEY_SENTINEL
1247 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1248 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1249 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1250 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1251 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1252#define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1254#define JSON_HEDLEY_SENTINEL(position)
1257#if defined(JSON_HEDLEY_NO_RETURN)
1258#undef JSON_HEDLEY_NO_RETURN
1260#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1261#define JSON_HEDLEY_NO_RETURN __noreturn
1263 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1264 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1265#define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1266#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1267#define JSON_HEDLEY_NO_RETURN _Noreturn
1268#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1269#define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1271 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1272 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1273 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1274 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1275 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1276 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1277 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1278 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1279 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1280 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1281 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1282 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1283 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1284 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1285 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1286 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1287 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1288#define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1289#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1290#define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1292 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1293 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1294#define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1295#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1296#define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1297#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1298#define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1299#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1300#define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1302#define JSON_HEDLEY_NO_RETURN
1305#if defined(JSON_HEDLEY_NO_ESCAPE)
1306#undef JSON_HEDLEY_NO_ESCAPE
1308#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1309#define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1311#define JSON_HEDLEY_NO_ESCAPE
1314#if defined(JSON_HEDLEY_UNREACHABLE)
1315#undef JSON_HEDLEY_UNREACHABLE
1317#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1318#undef JSON_HEDLEY_UNREACHABLE_RETURN
1320#if defined(JSON_HEDLEY_ASSUME)
1321#undef JSON_HEDLEY_ASSUME
1324 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1325 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1326 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1327#define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1328#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1329#define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1331 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1332 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1333#if defined(__cplusplus)
1334#define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1336#define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1340 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1341 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1342 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1343 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1344 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1345 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1346 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1347#define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1348#elif defined(JSON_HEDLEY_ASSUME)
1349#define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1351#if !defined(JSON_HEDLEY_ASSUME)
1352#if defined(JSON_HEDLEY_UNREACHABLE)
1353#define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1355#define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1358#if defined(JSON_HEDLEY_UNREACHABLE)
1360 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1361 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1362#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1364#define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1367#define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1369#if !defined(JSON_HEDLEY_UNREACHABLE)
1370#define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1374#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1375#pragma clang diagnostic ignored "-Wpedantic"
1377#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1378#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1380#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1381#if defined(__clang__)
1382#pragma clang diagnostic ignored "-Wvariadic-macros"
1383#elif defined(JSON_HEDLEY_GCC_VERSION)
1384#pragma GCC diagnostic ignored "-Wvariadic-macros"
1387#if defined(JSON_HEDLEY_NON_NULL)
1388#undef JSON_HEDLEY_NON_NULL
1391 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1392 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1393 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1394 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1395#define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1397#define JSON_HEDLEY_NON_NULL(...)
1401#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1402#undef JSON_HEDLEY_PRINTF_FORMAT
1404#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1405#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1406#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1407#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1409 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1410 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1411 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1412 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1413 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1414 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1415 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1416 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1417 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1418 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1419 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1420 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1421 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1422 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1423 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1424 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1425 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1426#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1427#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1428#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1430#define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1433#if defined(JSON_HEDLEY_CONSTEXPR)
1434#undef JSON_HEDLEY_CONSTEXPR
1436#if defined(__cplusplus)
1437#if __cplusplus >= 201103L
1438#define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1441#if !defined(JSON_HEDLEY_CONSTEXPR)
1442#define JSON_HEDLEY_CONSTEXPR
1445#if defined(JSON_HEDLEY_PREDICT)
1446#undef JSON_HEDLEY_PREDICT
1448#if defined(JSON_HEDLEY_LIKELY)
1449#undef JSON_HEDLEY_LIKELY
1451#if defined(JSON_HEDLEY_UNLIKELY)
1452#undef JSON_HEDLEY_UNLIKELY
1454#if defined(JSON_HEDLEY_UNPREDICTABLE)
1455#undef JSON_HEDLEY_UNPREDICTABLE
1457#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1458#define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1461 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1462 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1463 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1464# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1465# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1466# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1467# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1468# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1470 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1471 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1472 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1473 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1474 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1475 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1476 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1477 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1478 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1479 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1480 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1481 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1482 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1483 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1484 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1485 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1486# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1487 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1488# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1490 double hedley_probability_ = (probability); \
1491 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1493# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1495 double hedley_probability_ = (probability); \
1496 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1498# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1499# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1501# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1502# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1503# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1504# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1505# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1507#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1508#define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1511#if defined(JSON_HEDLEY_MALLOC)
1512#undef JSON_HEDLEY_MALLOC
1515 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1516 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1517 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1518 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1519 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1520 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1521 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1522 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1523 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1524 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1525 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1526 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1527 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1528 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1529 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1530 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1531 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1532 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1533#define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1534#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1535#define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1537 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1538 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1539#define JSON_HEDLEY_MALLOC __declspec(restrict)
1541#define JSON_HEDLEY_MALLOC
1544#if defined(JSON_HEDLEY_PURE)
1545#undef JSON_HEDLEY_PURE
1548 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1549 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1550 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1551 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1552 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1553 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1554 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1555 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1556 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1557 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1558 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1559 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1560 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1561 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1562 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1563 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1564 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1565 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1566 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1567# define JSON_HEDLEY_PURE __attribute__((__pure__))
1568#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1569# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1570#elif defined(__cplusplus) && \
1572 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1573 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1574 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1576# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1578# define JSON_HEDLEY_PURE
1581#if defined(JSON_HEDLEY_CONST)
1582#undef JSON_HEDLEY_CONST
1585 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1586 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1587 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1588 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1589 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1590 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1591 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1592 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1593 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1594 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1595 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1596 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1597 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1598 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1599 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1600 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1601 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1602 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1603 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1604#define JSON_HEDLEY_CONST __attribute__((__const__))
1606 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1607#define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1609#define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1612#if defined(JSON_HEDLEY_RESTRICT)
1613#undef JSON_HEDLEY_RESTRICT
1615#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1616#define JSON_HEDLEY_RESTRICT restrict
1618 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1619 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1620 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1621 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1622 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1623 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1624 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1625 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1626 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1627 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1628 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1629 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1630 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1631 defined(__clang__) || \
1632 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1633#define JSON_HEDLEY_RESTRICT __restrict
1634#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1635#define JSON_HEDLEY_RESTRICT _Restrict
1637#define JSON_HEDLEY_RESTRICT
1640#if defined(JSON_HEDLEY_INLINE)
1641#undef JSON_HEDLEY_INLINE
1644 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1645 (defined(__cplusplus) && (__cplusplus >= 199711L))
1646#define JSON_HEDLEY_INLINE inline
1648 defined(JSON_HEDLEY_GCC_VERSION) || \
1649 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1650#define JSON_HEDLEY_INLINE __inline__
1652 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1653 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1654 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1655 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1656 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1657 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1658 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1659 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1660 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1661 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1662#define JSON_HEDLEY_INLINE __inline
1664#define JSON_HEDLEY_INLINE
1667#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1668#undef JSON_HEDLEY_ALWAYS_INLINE
1671 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1672 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1673 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1674 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1675 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1676 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1677 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1678 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1679 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1680 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1681 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1682 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1683 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1684 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1685 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1686 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1687 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1688 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1689 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1690# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1692 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1693 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1694# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1695#elif defined(__cplusplus) && \
1697 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1698 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1699 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1700 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1701 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1702 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1704# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1705#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1706# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1708# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1711#if defined(JSON_HEDLEY_NEVER_INLINE)
1712#undef JSON_HEDLEY_NEVER_INLINE
1715 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1716 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1717 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1718 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1719 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1720 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1721 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1722 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1723 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1724 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1725 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1726 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1727 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1728 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1729 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1730 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1731 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1732 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1733 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1734#define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1736 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1737 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1738#define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1739#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1740#define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1741#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1742#define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1743#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1744#define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1745#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1746#define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1747#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1748#define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1750#define JSON_HEDLEY_NEVER_INLINE
1753#if defined(JSON_HEDLEY_PRIVATE)
1754#undef JSON_HEDLEY_PRIVATE
1756#if defined(JSON_HEDLEY_PUBLIC)
1757#undef JSON_HEDLEY_PUBLIC
1759#if defined(JSON_HEDLEY_IMPORT)
1760#undef JSON_HEDLEY_IMPORT
1762#if defined(_WIN32) || defined(__CYGWIN__)
1763# define JSON_HEDLEY_PRIVATE
1764# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1765# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1768 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1769 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1770 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1771 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1772 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1773 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1775 defined(__TI_EABI__) && \
1777 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1778 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1781 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1782# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1783# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1785# define JSON_HEDLEY_PRIVATE
1786# define JSON_HEDLEY_PUBLIC
1788# define JSON_HEDLEY_IMPORT extern
1791#if defined(JSON_HEDLEY_NO_THROW)
1792#undef JSON_HEDLEY_NO_THROW
1795 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1796 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1797 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1798 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1799#define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1801 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1802 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1803 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1804#define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1806#define JSON_HEDLEY_NO_THROW
1809#if defined(JSON_HEDLEY_FALL_THROUGH)
1810#undef JSON_HEDLEY_FALL_THROUGH
1813 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
1814 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
1815 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1816#define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
1817#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
1818#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
1819#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
1820#define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
1821#elif defined(__fallthrough)
1822#define JSON_HEDLEY_FALL_THROUGH __fallthrough
1824#define JSON_HEDLEY_FALL_THROUGH
1827#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
1828#undef JSON_HEDLEY_RETURNS_NON_NULL
1831 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
1832 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1833 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1834#define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
1835#elif defined(_Ret_notnull_)
1836#define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
1838#define JSON_HEDLEY_RETURNS_NON_NULL
1841#if defined(JSON_HEDLEY_ARRAY_PARAM)
1842#undef JSON_HEDLEY_ARRAY_PARAM
1845 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
1846 !defined(__STDC_NO_VLA__) && \
1847 !defined(__cplusplus) && \
1848 !defined(JSON_HEDLEY_PGI_VERSION) && \
1849 !defined(JSON_HEDLEY_TINYC_VERSION)
1850#define JSON_HEDLEY_ARRAY_PARAM(name) (name)
1852#define JSON_HEDLEY_ARRAY_PARAM(name)
1855#if defined(JSON_HEDLEY_IS_CONSTANT)
1856#undef JSON_HEDLEY_IS_CONSTANT
1858#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
1859#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
1863#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1864#undef JSON_HEDLEY_IS_CONSTEXPR_
1867 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
1868 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1869 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1870 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
1871 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1872 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1873 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1874 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
1875 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1876 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1877#define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
1879#if !defined(__cplusplus)
1881 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
1882 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1883 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1884 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1885 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1886 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1887 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
1888#if defined(__INTPTR_TYPE__)
1889#define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
1892#define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
1896 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
1897 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
1898 !defined(JSON_HEDLEY_PGI_VERSION) && \
1899 !defined(JSON_HEDLEY_IAR_VERSION)) || \
1900 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1901 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1902 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
1903 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1904 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
1905#if defined(__INTPTR_TYPE__)
1906#define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
1909#define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
1912 defined(JSON_HEDLEY_GCC_VERSION) || \
1913 defined(JSON_HEDLEY_INTEL_VERSION) || \
1914 defined(JSON_HEDLEY_TINYC_VERSION) || \
1915 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
1916 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
1917 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
1918 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
1919 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
1920 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
1922# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
1926 ((void*) ((expr) * 0L) ) : \
1927((struct { char v[sizeof(void) * 2]; } *) 1) \
1933#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1934#if !defined(JSON_HEDLEY_IS_CONSTANT)
1935#define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
1937#define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
1939#if !defined(JSON_HEDLEY_IS_CONSTANT)
1940#define JSON_HEDLEY_IS_CONSTANT(expr) (0)
1942#define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
1945#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
1946#undef JSON_HEDLEY_BEGIN_C_DECLS
1948#if defined(JSON_HEDLEY_END_C_DECLS)
1949#undef JSON_HEDLEY_END_C_DECLS
1951#if defined(JSON_HEDLEY_C_DECL)
1952#undef JSON_HEDLEY_C_DECL
1954#if defined(__cplusplus)
1955#define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
1956#define JSON_HEDLEY_END_C_DECLS }
1957#define JSON_HEDLEY_C_DECL extern "C"
1959#define JSON_HEDLEY_BEGIN_C_DECLS
1960#define JSON_HEDLEY_END_C_DECLS
1961#define JSON_HEDLEY_C_DECL
1964#if defined(JSON_HEDLEY_STATIC_ASSERT)
1965#undef JSON_HEDLEY_STATIC_ASSERT
1968 !defined(__cplusplus) && ( \
1969 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
1970 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1971 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
1972 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1973 defined(_Static_assert) \
1975# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
1977 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
1978 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
1979 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1980# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
1982# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
1985#if defined(JSON_HEDLEY_NULL)
1986#undef JSON_HEDLEY_NULL
1988#if defined(__cplusplus)
1989#if __cplusplus >= 201103L
1990#define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
1992#define JSON_HEDLEY_NULL NULL
1994#define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
1997#define JSON_HEDLEY_NULL NULL
1999#define JSON_HEDLEY_NULL ((void*) 0)
2002#if defined(JSON_HEDLEY_MESSAGE)
2003#undef JSON_HEDLEY_MESSAGE
2005#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2006# define JSON_HEDLEY_MESSAGE(msg) \
2007 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2008 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2009 JSON_HEDLEY_PRAGMA(message msg) \
2010 JSON_HEDLEY_DIAGNOSTIC_POP
2012 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2013 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2014# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2015#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2016# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2017#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2018# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2019#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2020# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2022# define JSON_HEDLEY_MESSAGE(msg)
2025#if defined(JSON_HEDLEY_WARNING)
2026#undef JSON_HEDLEY_WARNING
2028#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2029# define JSON_HEDLEY_WARNING(msg) \
2030 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2031 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2032 JSON_HEDLEY_PRAGMA(clang warning msg) \
2033 JSON_HEDLEY_DIAGNOSTIC_POP
2035 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2036 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2037 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2038# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2040 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2041 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2042# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2044# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2047#if defined(JSON_HEDLEY_REQUIRE)
2048#undef JSON_HEDLEY_REQUIRE
2050#if defined(JSON_HEDLEY_REQUIRE_MSG)
2051#undef JSON_HEDLEY_REQUIRE_MSG
2053#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2054# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2055# define JSON_HEDLEY_REQUIRE(expr) \
2056 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2057 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2058 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2059 JSON_HEDLEY_DIAGNOSTIC_POP
2060# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2061 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2062 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2063 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2064 JSON_HEDLEY_DIAGNOSTIC_POP
2066# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2067# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2070# define JSON_HEDLEY_REQUIRE(expr)
2071# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2074#if defined(JSON_HEDLEY_FLAGS)
2075#undef JSON_HEDLEY_FLAGS
2077#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2078#define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2080#define JSON_HEDLEY_FLAGS
2083#if defined(JSON_HEDLEY_FLAGS_CAST)
2084#undef JSON_HEDLEY_FLAGS_CAST
2086#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2087# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2088 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2089 _Pragma("warning(disable:188)") \
2091 JSON_HEDLEY_DIAGNOSTIC_POP \
2094# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2097#if defined(JSON_HEDLEY_EMPTY_BASES)
2098#undef JSON_HEDLEY_EMPTY_BASES
2101 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2102 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2103#define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2105#define JSON_HEDLEY_EMPTY_BASES
2110#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2111#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2113#if defined(__clang__)
2114#define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2116#define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2119#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2120#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2122#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2124#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2125#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2127#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2129#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2130#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2132#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2134#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2135#undef JSON_HEDLEY_CLANG_HAS_FEATURE
2137#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2139#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2140#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2142#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2144#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2145#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2147#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2149#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2150#undef JSON_HEDLEY_CLANG_HAS_WARNING
2152#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2159#include <type_traits>
2192 template<
class Default,
2194 template<
class...>
class Op,
2202 template<
class Default,
template<
class...>
class Op,
class... Args>
2209 template<
template<
class...>
class Op,
class... Args>
2212 template<
template<
class...>
class Op,
class... Args>
2215 template<
template<
class...>
class Op,
class... Args>
2218 template<
class Default,
template<
class...>
class Op,
class... Args>
2221 template<
class Default,
template<
class...>
class Op,
class... Args>
2224 template<
class Expected,
template<
class...>
class Op,
class... Args>
2227 template<
class To,
template<
class...>
class Op,
class... Args>
2229 std::is_convertible<
detected_t<Op, Args...>, To>;
2238#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2239#if defined(__clang__)
2240#if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2241#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2243#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2244#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2245#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2252#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2253#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2254#define JSON_HAS_CPP_20
2255#define JSON_HAS_CPP_17
2256#define JSON_HAS_CPP_14
2257#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2258#define JSON_HAS_CPP_17
2259#define JSON_HAS_CPP_14
2260#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2261#define JSON_HAS_CPP_14
2264#define JSON_HAS_CPP_11
2268#if __has_include(<version>)
2273#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2274#ifdef JSON_HAS_CPP_17
2275#if defined(__cpp_lib_filesystem)
2276#define JSON_HAS_FILESYSTEM 1
2277#elif defined(__cpp_lib_experimental_filesystem)
2278#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2279#elif !defined(__has_include)
2280#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2281#elif __has_include(<filesystem>)
2282#define JSON_HAS_FILESYSTEM 1
2283#elif __has_include(<experimental/filesystem>)
2284#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2288#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2289#undef JSON_HAS_FILESYSTEM
2290#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2294#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2295#undef JSON_HAS_FILESYSTEM
2296#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2300#if defined(__clang_major__) && __clang_major__ < 7
2301#undef JSON_HAS_FILESYSTEM
2302#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2306#if defined(_MSC_VER) && _MSC_VER < 1914
2307#undef JSON_HAS_FILESYSTEM
2308#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2312#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2313#undef JSON_HAS_FILESYSTEM
2314#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2318#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2319#undef JSON_HAS_FILESYSTEM
2320#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2325#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2326#define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2329#ifndef JSON_HAS_FILESYSTEM
2330#define JSON_HAS_FILESYSTEM 0
2333#ifndef JSON_HAS_THREE_WAY_COMPARISON
2334#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2335 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2336#define JSON_HAS_THREE_WAY_COMPARISON 1
2338#define JSON_HAS_THREE_WAY_COMPARISON 0
2342#ifndef JSON_HAS_RANGES
2344#if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2345#define JSON_HAS_RANGES 0
2346#elif defined(__cpp_lib_ranges)
2347#define JSON_HAS_RANGES 1
2349#define JSON_HAS_RANGES 0
2353#ifdef JSON_HAS_CPP_17
2354#define JSON_INLINE_VARIABLE inline
2356#define JSON_INLINE_VARIABLE
2359#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2360#define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2362#define JSON_NO_UNIQUE_ADDRESS
2366#if defined(__clang__)
2367#pragma clang diagnostic push
2368#pragma clang diagnostic ignored "-Wdocumentation"
2369#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2373#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2374#define JSON_THROW(exception) throw exception
2376#define JSON_CATCH(exception) catch(exception)
2377#define JSON_INTERNAL_CATCH(exception) catch(exception)
2380#define JSON_THROW(exception) std::abort()
2381#define JSON_TRY if(true)
2382#define JSON_CATCH(exception) if(false)
2383#define JSON_INTERNAL_CATCH(exception) if(false)
2387#if defined(JSON_THROW_USER)
2389#define JSON_THROW JSON_THROW_USER
2391#if defined(JSON_TRY_USER)
2393#define JSON_TRY JSON_TRY_USER
2395#if defined(JSON_CATCH_USER)
2397#define JSON_CATCH JSON_CATCH_USER
2398#undef JSON_INTERNAL_CATCH
2399#define JSON_INTERNAL_CATCH JSON_CATCH_USER
2401#if defined(JSON_INTERNAL_CATCH_USER)
2402#undef JSON_INTERNAL_CATCH
2403#define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2407#if !defined(JSON_ASSERT)
2409#define JSON_ASSERT(x) assert(x)
2413#if defined(JSON_TESTS_PRIVATE)
2414#define JSON_PRIVATE_UNLESS_TESTED public
2416#define JSON_PRIVATE_UNLESS_TESTED private
2424#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2425 template<typename BasicJsonType> \
2426 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2428 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2429 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2430 auto it = std::find_if(std::begin(m), std::end(m), \
2431 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2433 return ej_pair.first == e; \
2435 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2437 template<typename BasicJsonType> \
2438 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2440 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2441 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2442 auto it = std::find_if(std::begin(m), std::end(m), \
2443 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2445 return ej_pair.second == j; \
2447 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2453#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2454 template<template<typename, typename, typename...> class ObjectType, \
2455 template<typename, typename...> class ArrayType, \
2456 class StringType, class BooleanType, class NumberIntegerType, \
2457 class NumberUnsignedType, class NumberFloatType, \
2458 template<typename> class AllocatorType, \
2459 template<typename, typename = void> class JSONSerializer, \
2462#define NLOHMANN_BASIC_JSON_TPL \
2463 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2464 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2465 AllocatorType, JSONSerializer, BinaryType>
2469#define NLOHMANN_JSON_EXPAND( x ) x
2470#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
2471#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2472 NLOHMANN_JSON_PASTE64, \
2473 NLOHMANN_JSON_PASTE63, \
2474 NLOHMANN_JSON_PASTE62, \
2475 NLOHMANN_JSON_PASTE61, \
2476 NLOHMANN_JSON_PASTE60, \
2477 NLOHMANN_JSON_PASTE59, \
2478 NLOHMANN_JSON_PASTE58, \
2479 NLOHMANN_JSON_PASTE57, \
2480 NLOHMANN_JSON_PASTE56, \
2481 NLOHMANN_JSON_PASTE55, \
2482 NLOHMANN_JSON_PASTE54, \
2483 NLOHMANN_JSON_PASTE53, \
2484 NLOHMANN_JSON_PASTE52, \
2485 NLOHMANN_JSON_PASTE51, \
2486 NLOHMANN_JSON_PASTE50, \
2487 NLOHMANN_JSON_PASTE49, \
2488 NLOHMANN_JSON_PASTE48, \
2489 NLOHMANN_JSON_PASTE47, \
2490 NLOHMANN_JSON_PASTE46, \
2491 NLOHMANN_JSON_PASTE45, \
2492 NLOHMANN_JSON_PASTE44, \
2493 NLOHMANN_JSON_PASTE43, \
2494 NLOHMANN_JSON_PASTE42, \
2495 NLOHMANN_JSON_PASTE41, \
2496 NLOHMANN_JSON_PASTE40, \
2497 NLOHMANN_JSON_PASTE39, \
2498 NLOHMANN_JSON_PASTE38, \
2499 NLOHMANN_JSON_PASTE37, \
2500 NLOHMANN_JSON_PASTE36, \
2501 NLOHMANN_JSON_PASTE35, \
2502 NLOHMANN_JSON_PASTE34, \
2503 NLOHMANN_JSON_PASTE33, \
2504 NLOHMANN_JSON_PASTE32, \
2505 NLOHMANN_JSON_PASTE31, \
2506 NLOHMANN_JSON_PASTE30, \
2507 NLOHMANN_JSON_PASTE29, \
2508 NLOHMANN_JSON_PASTE28, \
2509 NLOHMANN_JSON_PASTE27, \
2510 NLOHMANN_JSON_PASTE26, \
2511 NLOHMANN_JSON_PASTE25, \
2512 NLOHMANN_JSON_PASTE24, \
2513 NLOHMANN_JSON_PASTE23, \
2514 NLOHMANN_JSON_PASTE22, \
2515 NLOHMANN_JSON_PASTE21, \
2516 NLOHMANN_JSON_PASTE20, \
2517 NLOHMANN_JSON_PASTE19, \
2518 NLOHMANN_JSON_PASTE18, \
2519 NLOHMANN_JSON_PASTE17, \
2520 NLOHMANN_JSON_PASTE16, \
2521 NLOHMANN_JSON_PASTE15, \
2522 NLOHMANN_JSON_PASTE14, \
2523 NLOHMANN_JSON_PASTE13, \
2524 NLOHMANN_JSON_PASTE12, \
2525 NLOHMANN_JSON_PASTE11, \
2526 NLOHMANN_JSON_PASTE10, \
2527 NLOHMANN_JSON_PASTE9, \
2528 NLOHMANN_JSON_PASTE8, \
2529 NLOHMANN_JSON_PASTE7, \
2530 NLOHMANN_JSON_PASTE6, \
2531 NLOHMANN_JSON_PASTE5, \
2532 NLOHMANN_JSON_PASTE4, \
2533 NLOHMANN_JSON_PASTE3, \
2534 NLOHMANN_JSON_PASTE2, \
2535 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2536#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2537#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2538#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2539#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2540#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2541#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2542#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2543#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2544#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2545#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2546#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2547#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2548#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2549#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2550#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2551#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2552#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2553#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2554#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2555#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2556#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2557#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2558#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2559#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2560#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2561#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2562#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2563#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2564#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2565#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2566#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2567#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2568#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2569#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2570#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2571#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2572#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2573#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2574#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2575#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2576#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2577#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2578#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2579#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2580#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2581#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2582#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2583#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2584#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2585#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2586#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2587#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2588#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2589#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2590#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2591#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2592#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2593#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2594#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2595#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2596#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2597#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2598#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2600#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2601#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2602#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2609#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2610 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2611 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2613#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2614 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2615 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2622#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2623 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2624 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2626#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2627 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2628 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2637#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2638 namespace detail { \
2639 using std::std_name; \
2641 template<typename... T> \
2642 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2645 namespace detail2 { \
2646 struct std_name##_tag \
2650 template<typename... T> \
2651 std_name##_tag std_name(T&&...); \
2653 template<typename... T> \
2654 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2656 template<typename... T> \
2657 struct would_call_std_##std_name \
2659 static constexpr auto const value = ::nlohmann::detail:: \
2660 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2664 template<typename... T> \
2665 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2669#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2670#define JSON_USE_IMPLICIT_CONVERSIONS 1
2673#if JSON_USE_IMPLICIT_CONVERSIONS
2674#define JSON_EXPLICIT
2676#define JSON_EXPLICIT explicit
2679#ifndef JSON_DIAGNOSTICS
2680#define JSON_DIAGNOSTICS 0
2683#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
2684#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
2687#if JSON_HAS_THREE_WAY_COMPARISON
2750#if JSON_HAS_THREE_WAY_COMPARISON
2751 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
2756 static constexpr std::array<std::uint8_t, 9> order = { {
2763 const auto l_index =
static_cast<std::size_t
>(lhs);
2764 const auto r_index =
static_cast<std::size_t
>(rhs);
2765#if JSON_HAS_THREE_WAY_COMPARISON
2766 if (l_index < order.size() && r_index < order.size())
2768 return order[l_index] <=> order[r_index];
2770 return std::partial_ordering::unordered;
2772 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2780#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
2783 return std::is_lt(lhs <=> rhs);
2813 template<
typename StringType>
2815 const StringType& t)
2818 for (
auto pos = s.find(f);
2819 pos != StringType::npos;
2820 s.replace(pos, f.size(), t),
2821 pos = s.find(f, pos + t.size()))
2833 template<
typename StringType>
2848 template<
typename StringType>
2849 static void unescape(StringType& s)
2878 constexpr operator size_t()
const
2893#include <type_traits>
2904 template<
typename T>
2905 using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
2907#ifdef JSON_HAS_CPP_14
2918 template<
bool B,
typename T =
void>
2945 template <
typename T, T... Ints>
2949 static constexpr std::size_t
size() noexcept
2951 return sizeof...(Ints);
2960 template <
size_t... Ints>
2963 namespace utility_internal
2966 template <
typename Seq,
size_t SeqSize,
size_t Rem>
2970 template <
typename T, T... Ints,
size_t SeqSize>
2976 template <
typename T, T... Ints,
size_t SeqSize>
2984 template <
typename T,
size_t N>
2991 template <
typename T>
3006 template <
typename T, T N>
3022 template <
typename... Ts>
3034 template<
typename T>
3040#ifndef JSON_HAS_CPP_17
3042 template<
typename T>
3054#include <type_traits>
3075 template<
typename It,
typename =
void>
3078 template<
typename It>
3082 typename It::reference, typename It::iterator_category >>
3093 template<
typename T,
typename =
void>
3098 template<
typename T>
3104 template<
typename T>
3143#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3144#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3166 template<
typename T =
void,
typename SFINAE =
void>
3167 struct adl_serializer;
3171 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3173 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3174 class StringType = std::string,
class BooleanType = bool,
3175 class NumberIntegerType = std::int64_t,
3176 class NumberUnsignedType = std::uint64_t,
3177 class NumberFloatType = double,
3178 template<
typename U>
class AllocatorType = std::allocator,
3179 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3181 class BinaryType = std::vector<std::uint8_t>>
3186 template<
typename BasicJsonType>
3197 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3242 template<
typename BasicJsonContext>
3244 std::integral_constant < bool,
3245 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3246 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3259 template<
typename T>
3266 template<
typename T>
3269 template<
typename T>
3272 template<
typename T>
3275 template<
typename T>
3278 template<
typename T>
3281 template<
typename T>
3284 template<
typename T>
3287 template<
typename T,
typename... Args>
3290 template<
typename T,
typename... Args>
3293 template<
typename T,
typename U>
3297 template<
typename BasicJsonType,
typename T,
typename =
void>
3304 template <
typename BasicJsonType,
typename T>
3310 template<
typename BasicJsonType,
typename T>
3313 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3317 const BasicJsonType&, T&>::value;
3322 template<
typename BasicJsonType,
typename T,
typename =
void>
3325 template<
typename BasicJsonType,
typename T>
3328 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3332 const BasicJsonType&>::value;
3337 template<
typename BasicJsonType,
typename T,
typename =
void>
3340 template<
typename BasicJsonType,
typename T>
3343 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3350 template<
typename T>
3353 template<
typename T>
3354 struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3357 template<
typename BasicJsonType>
3362 using type =
typename std::conditional < has_key_compare<object_t>::value,
3366 template<
typename BasicJsonType>
3376 template<
class B,
class... Bn>
3378 : std::conditional<bool(B::value), conjunction<Bn...>, B>::type {};
3381 template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3386 template <
typename T>
3389 template <
typename T1,
typename T2>
3391 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3393 template <
typename T1,
typename T2>
3395 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3397 template <
typename... Ts>
3399 :
conjunction<is_default_constructible<Ts>...> {};
3401 template <
typename... Ts>
3403 :
conjunction<is_default_constructible<Ts>...> {};
3406 template <
typename T,
typename... Args>
3409 template <
typename T1,
typename T2>
3412 template <
typename T1,
typename T2>
3415 template <
typename... Ts>
3418 template <
typename... Ts>
3422 template<
typename T,
typename =
void>
3425 template<
typename T>
3440 template<
typename T>
3444 using t_ref =
typename std::add_lvalue_reference<T>::type;
3452 static constexpr auto is_iterator_begin =
3456 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3459 template<
typename R>
3462 template<
typename T>
3469 template<
typename T,
typename =
void>
3472 template<
typename T>
3475 template<
typename BasicJsonType,
typename CompatibleObjectType,
3479 template<
typename BasicJsonType,
typename CompatibleObjectType>
3481 BasicJsonType, CompatibleObjectType,
3483 is_detected<key_type_t, CompatibleObjectType>::value >>
3490 typename CompatibleObjectType::key_type>::value &&
3492 typename CompatibleObjectType::mapped_type>::value;
3495 template<
typename BasicJsonType,
typename CompatibleObjectType>
3499 template<
typename BasicJsonType,
typename ConstructibleObjectType,
3503 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3505 BasicJsonType, ConstructibleObjectType,
3507 is_detected<key_type_t, ConstructibleObjectType>::value >>
3513 (std::is_move_assignable<ConstructibleObjectType>::value ||
3514 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3516 typename object_t::key_type>::value &&
3518 typename object_t::mapped_type,
3519 typename ConstructibleObjectType::mapped_type >::value)) ||
3521 typename ConstructibleObjectType::mapped_type>::value ||
3524 typename ConstructibleObjectType::mapped_type >::value);
3527 template<
typename BasicJsonType,
typename ConstructibleObjectType>
3530 ConstructibleObjectType> {};
3532 template<
typename BasicJsonType,
typename CompatibleStringType>
3539 template<
typename BasicJsonType,
typename ConstructibleStringType>
3543#ifdef __INTEL_COMPILER
3544 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3551 typename BasicJsonType::string_t>
::value;
3554 template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3557 template<
typename BasicJsonType,
typename CompatibleArrayType>
3559 BasicJsonType, CompatibleArrayType,
3562 is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value &&
3565 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >>
3572 template<
typename BasicJsonType,
typename CompatibleArrayType>
3576 template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3579 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3581 BasicJsonType, ConstructibleArrayType,
3583 typename BasicJsonType::value_type>::value >>
3584 : std::true_type {};
3586 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3588 BasicJsonType, ConstructibleArrayType,
3590 typename BasicJsonType::value_type>::value &&
3593 (std::is_move_assignable<ConstructibleArrayType>::value ||
3594 std::is_copy_assignable<ConstructibleArrayType>::value) &&
3595 is_detected<iterator_t, ConstructibleArrayType>::value&&
3596 is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&&
3597 is_detected<range_value_t, ConstructibleArrayType>::value &&
3600 !std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
3602 detected_t<range_value_t, ConstructibleArrayType >>::value >>
3608 typename BasicJsonType::array_t::value_type>::value ||
3616 template<
typename BasicJsonType,
typename ConstructibleArrayType>
3620 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3624 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3626 RealIntegerType, CompatibleNumberIntegerType,
3628 std::is_integral<CompatibleNumberIntegerType>::value &&
3629 !std::is_same<bool, CompatibleNumberIntegerType>::value >>
3637 CompatibleNumberIntegerType>::value &&
3638 CompatibleLimits::is_integer &&
3639 RealLimits::is_signed == CompatibleLimits::is_signed;
3642 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3645 CompatibleNumberIntegerType> {};
3647 template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3650 template<
typename BasicJsonType,
typename CompatibleType>
3652 BasicJsonType, CompatibleType,
3659 template<
typename BasicJsonType,
typename CompatibleType>
3663 template<
typename T1,
typename T2>
3666 template<
typename T1,
typename... Args>
3669 template<
typename BasicJsonType,
typename T>
3672 template<
typename BasicJsonType>
3675 template<
typename BasicJsonType>
3680 template<
template <
typename...>
class Primary,
typename T>
3683 template<
template <
typename...>
class Primary,
typename... Args>
3686 template<
typename T>
3690 template<
typename Compare,
typename A,
typename B,
typename =
void>
3693 template<
typename Compare,
typename A,
typename B>
3695 decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
3696 decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
3697 >> : std::true_type {};
3700 template<
typename BasicJsonType,
typename KeyType>
3702 typename BasicJsonType::object_comparator_t,
3706 template<
typename T>
3715 template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3719 && !(ExcludeObjectKeyType&& std::is_same<KeyType,
3720 typename BasicJsonType::object_t::key_type>::value)
3721 && (!RequireTransparentComparator ||
is_detected <
3723 typename BasicJsonType::object_comparator_t >::value)
3727 std::false_type >::type;
3729 template<
typename ObjectType,
typename KeyType>
3733 template<
typename BasicJsonType,
typename KeyType>
3737 typename BasicJsonType::object_t, KeyType >::value,
3739 std::false_type >::type;
3743 template <
typename T>
3753 template <
typename C>
static one test(
decltype(&C::capacity));
3756 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
3760 template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3763 return static_cast<T
>(
value);
3766 template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3797 template<
typename... Args>
3798 inline std::size_t
concat_length(
const char* cstr, Args&& ... rest);
3800 template<
typename StringType,
typename... Args>
3801 inline std::size_t
concat_length(
const StringType& str, Args&& ... rest);
3803 template<
typename... Args>
3809 template<
typename... Args>
3813 return ::strlen(cstr) +
concat_length(std::forward<Args>(rest)...);
3816 template<
typename StringType,
typename... Args>
3819 return str.size() +
concat_length(std::forward<Args>(rest)...);
3822 template<
typename OutStringType>
3826 template<
typename StringType,
typename Arg>
3829 template<
typename StringType,
typename Arg>
3832 template<
typename StringType,
typename Arg>
3835 template<
typename StringType,
typename Arg>
3838 template<
typename StringType,
typename Arg>
3841 template<
typename StringType,
typename Arg>
3844 template<
typename StringType,
typename Arg>
3845 using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
3847 template<
typename StringType,
typename Arg>
3850 template <
typename OutStringType,
typename Arg,
typename... Args,
3853 inline void concat_into(OutStringType& out, Arg&& arg, Args && ... rest);
3855 template <
typename OutStringType,
typename Arg,
typename... Args,
3859 inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
3861 template <
typename OutStringType,
typename Arg,
typename... Args,
3866 inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
3868 template<
typename OutStringType,
typename Arg,
typename... Args,
3870 inline void concat_into(OutStringType& out, Arg&& arg, Args && ... rest)
3872 out.append(std::forward<Arg>(arg));
3876 template <
typename OutStringType,
typename Arg,
typename... Args,
3877 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3878 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
3879 inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
3881 out += std::forward<Arg>(arg);
3885 template <
typename OutStringType,
typename Arg,
typename... Args,
3886 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3887 && !detect_string_can_append_op<OutStringType, Arg>::value
3888 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
3889 inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
3891 out.append(arg.begin(), arg.end());
3895 template <
typename OutStringType,
typename Arg,
typename... Args,
3896 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3897 && !detect_string_can_append_op<OutStringType, Arg>::value
3898 && !detect_string_can_append_iter<OutStringType, Arg>::value
3899 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
3900 inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
3902 out.append(arg.data(), arg.size());
3906 template<
typename OutStringType = std::string,
typename... Args>
3907 inline OutStringType
concat(Args && ... args)
3934 const char*
what() const noexcept
override
3944 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
3946 static std::string
name(
const std::string& ename,
int id_)
3956 template<
typename BasicJsonType>
3960 std::vector<std::string> tokens;
3961 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
3963 switch (current->m_parent->type())
3967 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
3969 if (¤t->m_parent->m_value.array->operator[](i) == current)
3980 for (
const auto& element : *current->m_parent->m_value.object)
3982 if (&element.second == current)
3984 tokens.emplace_back(element.first.c_str());
4009 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4010 [](
const std::string& a,
const std::string& b)
4012 return concat(a,
'/', detail::escape(b));
4014 return concat(
'(', str,
") ");
4016 static_cast<void>(leaf_element);
4023 std::runtime_error m;
4040 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4048 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4049 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4054 return { id_, byte_, w.c_str() };
4069 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4072 static std::string position_string(
const position_t& pos)
4084 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4088 return { id_, w.c_str() };
4102 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4106 return { id_, w.c_str() };
4119 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4123 return { id_, w.c_str() };
4136 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4140 return { id_, w.c_str() };
4174#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4175#include <experimental/filesystem>
4178 namespace std_fs = std::experimental::filesystem;
4180#elif JSON_HAS_FILESYSTEM
4181#include <filesystem>
4184 namespace std_fs = std::filesystem;
4192 template<
typename BasicJsonType>
4193 inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4203 template <
typename BasicJsonType,
typename ArithmeticType,
4204 enable_if_t < std::is_arithmetic<ArithmeticType>::value &&
4205 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4209 switch (
static_cast<value_t>(j))
4213 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4218 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4223 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4239 template<
typename BasicJsonType>
4240 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4246 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4249 template<
typename BasicJsonType>
4250 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4256 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4260 typename BasicJsonType,
typename StringType,
4262 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4263 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4264 && !is_json_ref<StringType>::value,
int > = 0 >
4265 inline void from_json(
const BasicJsonType& j, StringType& s)
4272 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4275 template<
typename BasicJsonType>
4276 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4281 template<
typename BasicJsonType>
4282 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4287 template<
typename BasicJsonType>
4288 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4293 template<
typename BasicJsonType,
typename EnumType,
4294 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4297 typename std::underlying_type<EnumType>::type val;
4299 e =
static_cast<EnumType
>(val);
4303 template<
typename BasicJsonType,
typename T,
typename Allocator,
4304 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4305 inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4312 std::transform(j.rbegin(), j.rend(),
4313 std::front_inserter(l), [](
const BasicJsonType& i)
4315 return i.template get<T>();
4320 template<
typename BasicJsonType,
typename T,
4321 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4322 inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
4329 std::transform(j.begin(), j.end(),
std::begin(l),
4330 [](
const BasicJsonType& elem)
4332 return elem.template get<T>();
4336 template<
typename BasicJsonType,
typename T, std::
size_t N>
4338 ->
decltype(j.template get<T>(), void())
4340 for (std::size_t i = 0; i < N; ++i)
4342 arr[i] = j.at(i).template get<T>();
4346 template<
typename BasicJsonType>
4349 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4352 template<
typename BasicJsonType,
typename T, std::
size_t N>
4355 ->
decltype(j.template get<T>(), void())
4357 for (std::size_t i = 0; i < N; ++i)
4359 arr[i] = j.at(i).template get<T>();
4363 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4365 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4369 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4370 j.template get<typename ConstructibleArrayType::value_type>(),
4375 ConstructibleArrayType ret;
4376 ret.reserve(j.size());
4377 std::transform(j.begin(), j.end(),
4378 std::inserter(ret,
end(ret)), [](
const BasicJsonType& i)
4382 return i.template get<typename ConstructibleArrayType::value_type>();
4384 arr = std::move(ret);
4387 template<
typename BasicJsonType,
typename ConstructibleArrayType,
4389 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4396 ConstructibleArrayType ret;
4398 j.begin(), j.end(), std::inserter(ret,
end(ret)),
4399 [](
const BasicJsonType& i)
4403 return i.template get<typename ConstructibleArrayType::value_type>();
4405 arr = std::move(ret);
4408 template <
typename BasicJsonType,
typename ConstructibleArrayType,
4410 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value &&
4411 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value &&
4413 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value &&
4414 !is_basic_json<ConstructibleArrayType>::value,
4416 auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4418 j.template get<typename ConstructibleArrayType::value_type>(),
4429 template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4433 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4436 template <
typename BasicJsonType,
typename T, std::
size_t N >
4448 template<
typename BasicJsonType>
4449 inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4456 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4459 template<
typename BasicJsonType,
typename ConstructibleObjectType,
4460 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4461 inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4468 ConstructibleObjectType ret;
4469 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4470 using value_type =
typename ConstructibleObjectType::value_type;
4472 inner_object->begin(), inner_object->end(),
4473 std::inserter(ret, ret.begin()),
4474 [](
typename BasicJsonType::object_t::value_type
const& p)
4476 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4478 obj = std::move(ret);
4485 template <
typename BasicJsonType,
typename ArithmeticType,
4487 std::is_arithmetic<ArithmeticType>::value &&
4488 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value &&
4489 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value &&
4490 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value &&
4491 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4493 inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
4495 switch (
static_cast<value_t>(j))
4499 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4504 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4509 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4514 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4529 template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4532 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4535 template <
typename BasicJsonType,
class A1,
class A2 >
4538 return { std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4539 std::forward<BasicJsonType>(j).at(1).template get<A2>() };
4542 template<
typename BasicJsonType,
typename A1,
typename A2>
4548 template<
typename BasicJsonType,
typename... Args>
4554 template<
typename BasicJsonType,
typename... Args>
4560 template<
typename BasicJsonType,
typename TupleRelated>
4569 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4572 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4574 typename BasicJsonType::string_t, Key >::value >>
4575 inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4582 for (
const auto& p : j)
4588 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4592 template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4594 typename BasicJsonType::string_t, Key >::value >>
4595 inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4602 for (
const auto& p : j)
4608 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4612#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4613 template<
typename BasicJsonType>
4614 inline void from_json(
const BasicJsonType& j, std_fs::path& p)
4620 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4626 template<
typename BasicJsonType,
typename T>
4628 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
4629 ->
decltype(
from_json(j, std::forward<T>(val)))
4631 return from_json(j, std::forward<T>(val));
4636#ifndef JSON_HAS_CPP_17
4645#ifndef JSON_HAS_CPP_17
4657#include <type_traits>
4686 template<
typename string_type>
4701 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype(std::declval<IteratorType>().
key()) >::type >::type;
4705 IteratorType anchor{};
4707 std::size_t array_index = 0;
4709 mutable std::size_t array_index_last = 0;
4718 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
4720 : anchor(
std::move(it))
4721 , array_index(array_index_)
4728 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
4731 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
4761 return anchor == o.anchor;
4767 return anchor != o.anchor;
4775 switch (anchor.m_object->type())
4780 if (array_index != array_index_last)
4783 array_index_last = array_index;
4785 return array_index_str;
4790 return anchor.key();
4807 typename IteratorType::reference
value()
const
4809 return anchor.value();
4818 typename IteratorType::pointer container =
nullptr;
4825 : container(&cont) {}
4849 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
4857 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
4871#if defined(__clang__)
4873#pragma clang diagnostic push
4874#pragma clang diagnostic ignored "-Wmismatched-tags"
4876 template<
typename IteratorType>
4878 :
public std::integral_constant<std::size_t, 2> {};
4880 template<std::
size_t N,
typename IteratorType>
4885 get<N>(std::declval <
4888#if defined(__clang__)
4889#pragma clang diagnostic pop
4894template <
typename IteratorType>
4895inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
4905#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4906#include <experimental/filesystem>
4909 namespace std_fs = std::experimental::filesystem;
4911#elif JSON_HAS_FILESYSTEM
4912#include <filesystem>
4915 namespace std_fs = std::filesystem;
4939 template<
typename BasicJsonType>
4940 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
4942 j.m_value.destroy(j.m_type);
4945 j.assert_invariant();
4952 template<
typename BasicJsonType>
4953 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
4955 j.m_value.destroy(j.m_type);
4958 j.assert_invariant();
4961 template<
typename BasicJsonType>
4962 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4964 j.m_value.destroy(j.m_type);
4966 j.m_value = std::move(s);
4967 j.assert_invariant();
4970 template <
typename BasicJsonType,
typename CompatibleStringType,
4973 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
4975 j.m_value.destroy(j.m_type);
4977 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4978 j.assert_invariant();
4985 template<
typename BasicJsonType>
4986 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
4988 j.m_value.destroy(j.m_type);
4990 j.m_value =
typename BasicJsonType::binary_t(b);
4991 j.assert_invariant();
4994 template<
typename BasicJsonType>
4995 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
4997 j.m_value.destroy(j.m_type);
4999 j.m_value =
typename BasicJsonType::binary_t(std::move(b));
5000 j.assert_invariant();
5007 template<
typename BasicJsonType>
5008 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5010 j.m_value.destroy(j.m_type);
5013 j.assert_invariant();
5020 template<
typename BasicJsonType>
5021 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5023 j.m_value.destroy(j.m_type);
5026 j.assert_invariant();
5033 template<
typename BasicJsonType>
5034 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5036 j.m_value.destroy(j.m_type);
5039 j.assert_invariant();
5046 template<
typename BasicJsonType>
5047 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5049 j.m_value.destroy(j.m_type);
5053 j.assert_invariant();
5056 template<
typename BasicJsonType>
5057 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5059 j.m_value.destroy(j.m_type);
5061 j.m_value = std::move(arr);
5063 j.assert_invariant();
5066 template <
typename BasicJsonType,
typename CompatibleArrayType,
5069 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5074 j.m_value.destroy(j.m_type);
5076 j.m_value.array = j.template create<typename BasicJsonType::array_t>(
begin(arr),
end(arr));
5078 j.assert_invariant();
5081 template<
typename BasicJsonType>
5082 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5084 j.m_value.destroy(j.m_type);
5087 j.m_value.array->reserve(arr.size());
5088 for (
const bool x : arr)
5090 j.m_value.array->push_back(x);
5091 j.set_parent(j.m_value.array->back());
5093 j.assert_invariant();
5096 template<
typename BasicJsonType,
typename T,
5098 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5100 j.m_value.destroy(j.m_type);
5103 j.m_value.array->resize(arr.size());
5109 j.assert_invariant();
5116 template<
typename BasicJsonType>
5117 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5119 j.m_value.destroy(j.m_type);
5123 j.assert_invariant();
5126 template<
typename BasicJsonType>
5127 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5129 j.m_value.destroy(j.m_type);
5131 j.m_value = std::move(obj);
5133 j.assert_invariant();
5136 template <
typename BasicJsonType,
typename CompatibleObjectType,
5138 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5143 j.m_value.destroy(j.m_type);
5145 j.m_value.object = j.template create<typename BasicJsonType::object_t>(
begin(obj),
end(obj));
5147 j.assert_invariant();
5155 template<
typename BasicJsonType,
typename T,
5156 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5157 inline void to_json(BasicJsonType& j, T b)
noexcept
5162 template<
typename BasicJsonType,
typename CompatibleString,
5163 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5164 inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5169 template<
typename BasicJsonType>
5170 inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5175 template<
typename BasicJsonType,
typename FloatType,
5176 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5177 inline void to_json(BasicJsonType& j, FloatType val)
noexcept
5182 template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5183 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5184 inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
5189 template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5190 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5191 inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
5196 template<
typename BasicJsonType,
typename EnumType,
5197 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5198 inline void to_json(BasicJsonType& j, EnumType e)
noexcept
5200 using underlying_type =
typename std::underlying_type<EnumType>::type;
5204 template<
typename BasicJsonType>
5205 inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5210 template <
typename BasicJsonType,
typename CompatibleArrayType,
5211 enable_if_t < is_compatible_array_type<BasicJsonType,
5212 CompatibleArrayType>::value &&
5213 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value &&
5215 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value &&
5216 !is_basic_json<CompatibleArrayType>::value,
5218 inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5223 template<
typename BasicJsonType>
5224 inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5229 template<
typename BasicJsonType,
typename T,
5230 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5231 inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5236 template<
typename BasicJsonType>
5237 inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5242 template <
typename BasicJsonType,
typename CompatibleObjectType,
5243 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value && !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
5244 inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5249 template<
typename BasicJsonType>
5250 inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5256 typename BasicJsonType,
typename T, std::size_t N,
5257 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5258 const T(&)[N]>::value,
5260 inline void to_json(BasicJsonType& j,
const T(&arr)[N])
5265 template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5266 inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
5268 j = { p.first, p.second };
5272 template<
typename BasicJsonType,
typename T,
5273 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value,
int> = 0>
5276 j = { {b.key(), b.value()} };
5279 template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5282 j = { std::get<Idx>(t)... };
5285 template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5286 inline void to_json(BasicJsonType& j,
const T& t)
5291#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5292 template<
typename BasicJsonType>
5293 inline void to_json(BasicJsonType& j,
const std_fs::path& p)
5301 template<
typename BasicJsonType,
typename T>
5302 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
5303 ->
decltype(
to_json(j, std::forward<T>(val)), void())
5305 return to_json(j, std::forward<T>(val));
5310#ifndef JSON_HAS_CPP_17
5319#ifndef JSON_HAS_CPP_17
5333 template<
typename ValueType,
typename>
5338 template<
typename BasicJsonType,
typename TargetType = ValueType>
5339 static auto from_json(BasicJsonType&& j, TargetType& val)
noexcept(
5348 template<
typename BasicJsonType,
typename TargetType = ValueType>
5358 template<
typename BasicJsonType,
typename TargetType = ValueType>
5359 static auto to_json(BasicJsonType& j, TargetType&& val)
noexcept(
5380 template<
typename BinaryType>
5405 , m_subtype(subtype_)
5406 , m_has_subtype(
true)
5412 , m_subtype(subtype_)
5413 , m_has_subtype(
true)
5418 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
5419 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
5424 return !(rhs == *
this);
5431 m_subtype = subtype_;
5432 m_has_subtype =
true;
5439 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
5446 return m_has_subtype;
5454 m_has_subtype =
false;
5459 bool m_has_subtype =
false;
5475#include <functional>
5488 inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
5490 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5505 template<
typename BasicJsonType>
5506 std::size_t
hash(
const BasicJsonType& j)
5508 using string_t =
typename BasicJsonType::string_t;
5509 using number_integer_t =
typename BasicJsonType::number_integer_t;
5510 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5511 using number_float_t =
typename BasicJsonType::number_float_t;
5513 const auto type =
static_cast<std::size_t
>(j.type());
5516 case BasicJsonType::value_t::null:
5517 case BasicJsonType::value_t::discarded:
5522 case BasicJsonType::value_t::object:
5524 auto seed =
combine(type, j.size());
5525 for (
const auto& element : j.items())
5527 const auto h = std::hash<string_t>{}(element.key());
5534 case BasicJsonType::value_t::array:
5536 auto seed =
combine(type, j.size());
5537 for (
const auto& element : j)
5544 case BasicJsonType::value_t::string:
5546 const auto h = std::hash<string_t>{}(j.template get_ref<const string_t&>());
5550 case BasicJsonType::value_t::boolean:
5552 const auto h = std::hash<bool>{}(j.template get<bool>());
5556 case BasicJsonType::value_t::number_integer:
5558 const auto h = std::hash<number_integer_t>{}(j.template get<number_integer_t>());
5562 case BasicJsonType::value_t::number_unsigned:
5564 const auto h = std::hash<number_unsigned_t>{}(j.template get<number_unsigned_t>());
5568 case BasicJsonType::value_t::number_float:
5570 const auto h = std::hash<number_float_t>{}(j.template get<number_float_t>());
5574 case BasicJsonType::value_t::binary:
5576 auto seed =
combine(type, j.get_binary().size());
5577 const auto h = std::hash<bool>{}(j.get_binary().has_subtype());
5579 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
5580 for (
const auto byte : j.get_binary())
5582 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
5625#include <type_traits>
5673 return std::fgetc(m_file);
5702 is->clear(is->rdstate() & std::ios::eofbit);
5707 : is(&i), sb(i.rdbuf())
5716 : is(rhs.is), sb(rhs.sb)
5727 auto res = sb->sbumpc();
5731 is->clear(is->rdstate() | std::ios::eofbit);
5738 std::istream* is =
nullptr;
5739 std::streambuf* sb =
nullptr;
5745 template<
typename IteratorType>
5749 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
5752 : current(
std::move(first)), end(
std::move(last))
5759 auto result = std::char_traits<char_type>::to_int_type(*current);
5760 std::advance(current, 1);
5764 return std::char_traits<char_type>::eof();
5768 IteratorType current;
5771 template<
typename BaseInputAdapter,
size_t T>
5776 return current ==
end;
5781 template<
typename BaseInputAdapter,
size_t T>
5784 template<
typename BaseInputAdapter>
5789 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5790 size_t& utf8_bytes_index,
5791 size_t& utf8_bytes_filled)
5793 utf8_bytes_index = 0;
5797 utf8_bytes[0] = std::char_traits<char>::eof();
5798 utf8_bytes_filled = 1;
5803 const auto wc = input.get_character();
5808 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5809 utf8_bytes_filled = 1;
5811 else if (wc <= 0x7FF)
5813 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5814 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5815 utf8_bytes_filled = 2;
5817 else if (wc <= 0xFFFF)
5819 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5820 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5821 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5822 utf8_bytes_filled = 3;
5824 else if (wc <= 0x10FFFF)
5826 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5827 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5828 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5829 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5830 utf8_bytes_filled = 4;
5835 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5836 utf8_bytes_filled = 1;
5842 template<
typename BaseInputAdapter>
5847 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5848 size_t& utf8_bytes_index,
5849 size_t& utf8_bytes_filled)
5851 utf8_bytes_index = 0;
5855 utf8_bytes[0] = std::char_traits<char>::eof();
5856 utf8_bytes_filled = 1;
5861 const auto wc = input.get_character();
5866 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5867 utf8_bytes_filled = 1;
5869 else if (wc <= 0x7FF)
5871 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
5872 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5873 utf8_bytes_filled = 2;
5875 else if (0xD800 > wc || wc >= 0xE000)
5877 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
5878 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5879 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5880 utf8_bytes_filled = 3;
5886 const auto wc2 =
static_cast<unsigned int>(input.get_character());
5887 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5888 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
5889 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
5890 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
5891 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
5892 utf8_bytes_filled = 4;
5896 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5897 utf8_bytes_filled = 1;
5905 template<
typename BaseInputAdapter,
typename W
ideCharType>
5912 : base_adapter(base) {}
5917 if (utf8_bytes_index == utf8_bytes_filled)
5919 fill_buffer<sizeof(WideCharType)>();
5927 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
5928 return utf8_bytes[utf8_bytes_index++];
5932 BaseInputAdapter base_adapter;
5941 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = { {0, 0, 0, 0} };
5944 std::size_t utf8_bytes_index = 0;
5946 std::size_t utf8_bytes_filled = 0;
5950 template<
typename IteratorType,
typename Enable =
void>
5954 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5959 return adapter_type(std::move(first), std::move(last));
5963 template<
typename T>
5973 template<
typename IteratorType>
5977 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5988 template<
typename IteratorType>
5992 return factory_type::create(first, last);
5999 namespace container_input_adapter_factory_impl
6005 template<
typename ContainerType,
typename Enable =
void>
6008 template<
typename ContainerType>
6010 void_t<decltype(
begin(
std::declval<ContainerType>()),
end(std::declval<ContainerType>()))>>
6022 template<
typename ContainerType>
6049 template <
typename CharT,
6050 typename std::enable_if <
6051 std::is_pointer<CharT>::value &&
6052 !std::is_array<CharT>::value&&
6053 std::is_integral<typename std::remove_pointer<CharT>::type>::value &&
6054 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6058 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
6059 const auto* ptr =
reinterpret_cast<const char*
>(b);
6063 template<
typename T, std::
size_t N>
6075 template <
typename CharT,
6076 typename std::enable_if <
6077 std::is_pointer<CharT>::value&&
6078 std::is_integral<typename std::remove_pointer<CharT>::type>::value &&
6079 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6082 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
6084 template<
class IteratorType,
6085 typename std::enable_if<
6086 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
6093 return std::move(ia);
6128 template<
typename BasicJsonType>
6232 const std::string& last_token,
6259 template<
typename BasicJsonType>
6275 : root(r), allow_exceptions(allow_exceptions_)
6287 handle_value(
nullptr);
6323 handle_value(std::move(val));
6329 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6331 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6345 object_element = &(ref_stack.back()->m_value.object->operator[](val));
6354 ref_stack.back()->set_parents();
6355 ref_stack.pop_back();
6361 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6363 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6376 ref_stack.back()->set_parents();
6377 ref_stack.pop_back();
6381 template<
class Exception>
6383 const Exception& ex)
6386 static_cast<void>(ex);
6387 if (allow_exceptions)
6406 template<
typename Value>
6408 BasicJsonType* handle_value(Value&& v)
6410 if (ref_stack.empty())
6412 root = BasicJsonType(std::forward<Value>(v));
6416 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6418 if (ref_stack.back()->is_array())
6420 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6421 return &(ref_stack.back()->m_value.array->back());
6426 *object_element = BasicJsonType(std::forward<Value>(v));
6427 return object_element;
6431 BasicJsonType& root;
6433 std::vector<BasicJsonType*> ref_stack{};
6435 BasicJsonType* object_element =
nullptr;
6437 bool errored =
false;
6439 const bool allow_exceptions =
true;
6442 template<
typename BasicJsonType>
6456 const bool allow_exceptions_ =
true)
6457 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6459 keep_stack.push_back(
true);
6471 handle_value(
nullptr);
6507 handle_value(std::move(val));
6514 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
6515 keep_stack.push_back(keep);
6517 auto val = handle_value(BasicJsonType::value_t::object,
true);
6518 ref_stack.push_back(val.second);
6521 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6531 BasicJsonType k = BasicJsonType(val);
6534 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
6535 key_keep_stack.push_back(keep);
6538 if (keep && ref_stack.back())
6540 object_element = &(ref_stack.back()->m_value.object->operator[](val) =
discarded);
6548 if (ref_stack.back())
6550 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
6557 ref_stack.back()->set_parents();
6563 ref_stack.pop_back();
6564 keep_stack.pop_back();
6566 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6569 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6571 if (it->is_discarded())
6573 ref_stack.back()->erase(it);
6584 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
6585 keep_stack.push_back(keep);
6587 auto val = handle_value(BasicJsonType::value_t::array,
true);
6588 ref_stack.push_back(val.second);
6591 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6603 if (ref_stack.back())
6605 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
6608 ref_stack.back()->set_parents();
6619 ref_stack.pop_back();
6620 keep_stack.pop_back();
6623 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
6625 ref_stack.back()->m_value.array->pop_back();
6631 template<
class Exception>
6633 const Exception& ex)
6636 static_cast<void>(ex);
6637 if (allow_exceptions)
6665 template<
typename Value>
6666 std::pair<bool, BasicJsonType*> handle_value(Value&& v,
const bool skip_callback =
false)
6672 if (!keep_stack.back())
6674 return {
false,
nullptr };
6678 auto value = BasicJsonType(std::forward<Value>(v));
6681 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value, value);
6686 return {
false,
nullptr };
6689 if (ref_stack.empty())
6691 root = std::move(value);
6692 return {
true, &root };
6697 if (!ref_stack.back())
6699 return {
false,
nullptr };
6703 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6706 if (ref_stack.back()->is_array())
6708 ref_stack.back()->m_value.array->emplace_back(std::move(value));
6709 return {
true, &(ref_stack.back()->m_value.array->back()) };
6716 const bool store_element = key_keep_stack.back();
6717 key_keep_stack.pop_back();
6721 return {
false,
nullptr };
6725 *object_element = std::move(value);
6726 return {
true, object_element };
6730 BasicJsonType& root;
6732 std::vector<BasicJsonType*> ref_stack{};
6734 std::vector<bool> keep_stack{};
6736 std::vector<bool> key_keep_stack{};
6738 BasicJsonType* object_element =
nullptr;
6740 bool errored =
false;
6744 const bool allow_exceptions =
true;
6746 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
6749 template<
typename BasicJsonType>
6836#include <initializer_list>
6856 template<
typename BasicJsonType>
6890 return "<uninitialized>";
6892 return "true literal";
6894 return "false literal";
6896 return "null literal";
6898 return "string literal";
6902 return "number literal";
6916 return "<parse error>";
6918 return "end of input";
6920 return "'[', '{', or a literal";
6923 return "unknown token";
6933 template<
typename BasicJsonType,
typename InputAdapterType>
6936 using number_integer_t =
typename BasicJsonType::number_integer_t;
6937 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6938 using number_float_t =
typename BasicJsonType::number_float_t;
6939 using string_t =
typename BasicJsonType::string_t;
6940 using char_type =
typename InputAdapterType::char_type;
6941 using char_int_type =
typename std::char_traits<char_type>::int_type;
6946 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
6947 : ia(
std::move(adapter))
6948 , ignore_comments(ignore_comments_)
6949 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
6966 static char get_decimal_point() noexcept
6968 const auto* loc = localeconv();
6970 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
6998 const auto factors = { 12u, 8u, 4u, 0u };
6999 for (
const auto factor : factors)
7003 if (current >=
'0' && current <=
'9')
7005 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7007 else if (current >=
'A' && current <=
'F')
7009 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7011 else if (current >=
'a' && current <=
'f')
7013 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7021 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7040 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
7042 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7045 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7054 error_message =
"invalid string: ill-formed UTF-8 byte";
7091 case std::char_traits<char_type>::eof():
7093 error_message =
"invalid string: missing closing quote";
7094 return token_type::parse_error;
7100 return token_type::value_string;
7144 const int codepoint1 = get_codepoint();
7145 int codepoint = codepoint1;
7149 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7150 return token_type::parse_error;
7154 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7159 const int codepoint2 = get_codepoint();
7163 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7164 return token_type::parse_error;
7171 codepoint =
static_cast<int>(
7173 (
static_cast<unsigned int>(codepoint1) << 10u)
7175 +
static_cast<unsigned int>(codepoint2)
7183 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7184 return token_type::parse_error;
7189 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7190 return token_type::parse_error;
7197 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7198 return token_type::parse_error;
7203 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7206 if (codepoint < 0x80)
7209 add(
static_cast<char_int_type
>(codepoint));
7211 else if (codepoint <= 0x7FF)
7214 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7215 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7217 else if (codepoint <= 0xFFFF)
7220 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7221 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7222 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7227 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7228 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7229 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7230 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7238 error_message =
"invalid string: forbidden character after backslash";
7239 return token_type::parse_error;
7248 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7249 return token_type::parse_error;
7254 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7255 return token_type::parse_error;
7260 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7261 return token_type::parse_error;
7266 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7267 return token_type::parse_error;
7272 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7273 return token_type::parse_error;
7278 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7279 return token_type::parse_error;
7284 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7285 return token_type::parse_error;
7290 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7291 return token_type::parse_error;
7296 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7297 return token_type::parse_error;
7302 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7303 return token_type::parse_error;
7308 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7309 return token_type::parse_error;
7314 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7315 return token_type::parse_error;
7320 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7321 return token_type::parse_error;
7326 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7327 return token_type::parse_error;
7332 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7333 return token_type::parse_error;
7338 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7339 return token_type::parse_error;
7344 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7345 return token_type::parse_error;
7350 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7351 return token_type::parse_error;
7356 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7357 return token_type::parse_error;
7362 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7363 return token_type::parse_error;
7368 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7369 return token_type::parse_error;
7374 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7375 return token_type::parse_error;
7380 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7381 return token_type::parse_error;
7386 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7387 return token_type::parse_error;
7392 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7393 return token_type::parse_error;
7398 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7399 return token_type::parse_error;
7404 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7405 return token_type::parse_error;
7410 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7411 return token_type::parse_error;
7416 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7417 return token_type::parse_error;
7422 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7423 return token_type::parse_error;
7428 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7429 return token_type::parse_error;
7434 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7435 return token_type::parse_error;
7572 return token_type::parse_error;
7582 return token_type::parse_error;
7606 return token_type::parse_error;
7616 return token_type::parse_error;
7626 return token_type::parse_error;
7638 return token_type::parse_error;
7648 return token_type::parse_error;
7656 error_message =
"invalid string: ill-formed UTF-8 byte";
7657 return token_type::parse_error;
7680 case std::char_traits<char_type>::eof():
7697 case std::char_traits<char_type>::eof():
7700 error_message =
"invalid comment; missing closing '*/'";
7728 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7735 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7737 f = std::strtof(str, endptr);
7741 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7743 f = std::strtod(str, endptr);
7747 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7749 f = std::strtold(str, endptr);
7792 token_type scan_number()
7799 token_type number_type = token_type::value_unsigned;
7807 goto scan_number_minus;
7813 goto scan_number_zero;
7827 goto scan_number_any1;
7837 number_type = token_type::value_integer;
7843 goto scan_number_zero;
7857 goto scan_number_any1;
7862 error_message =
"invalid number; expected digit after '-'";
7863 return token_type::parse_error;
7873 add(decimal_point_char);
7874 goto scan_number_decimal1;
7881 goto scan_number_exponent;
7885 goto scan_number_done;
7904 goto scan_number_any1;
7909 add(decimal_point_char);
7910 goto scan_number_decimal1;
7917 goto scan_number_exponent;
7921 goto scan_number_done;
7924 scan_number_decimal1:
7926 number_type = token_type::value_float;
7941 goto scan_number_decimal2;
7946 error_message =
"invalid number; expected digit after '.'";
7947 return token_type::parse_error;
7951 scan_number_decimal2:
7967 goto scan_number_decimal2;
7974 goto scan_number_exponent;
7978 goto scan_number_done;
7981 scan_number_exponent:
7983 number_type = token_type::value_float;
7990 goto scan_number_sign;
8005 goto scan_number_any2;
8011 "invalid number; expected '+', '-', or digit after exponent";
8012 return token_type::parse_error;
8032 goto scan_number_any2;
8037 error_message =
"invalid number; expected digit after exponent sign";
8038 return token_type::parse_error;
8058 goto scan_number_any2;
8062 goto scan_number_done;
8070 char* endptr =
nullptr;
8074 if (number_type == token_type::value_unsigned)
8076 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8079 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8083 value_unsigned =
static_cast<number_unsigned_t
>(x);
8084 if (value_unsigned == x)
8086 return token_type::value_unsigned;
8090 else if (number_type == token_type::value_integer)
8092 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8095 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8099 value_integer =
static_cast<number_integer_t
>(x);
8100 if (value_integer == x)
8102 return token_type::value_integer;
8109 strtof(value_float, token_buffer.data(), &endptr);
8112 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8114 return token_type::value_float;
8123 token_type scan_literal(const char_type* literal_text, const
std::
size_t length,
8124 token_type return_type)
8126 JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
8127 for (std::size_t i = 1; i < length; ++i)
8131 error_message =
"invalid literal";
8132 return token_type::parse_error;
8143 void reset() noexcept
8145 token_buffer.clear();
8146 token_string.clear();
8147 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8162 ++position.chars_read_total;
8163 ++position.chars_read_current_line;
8172 current = ia.get_character();
8177 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8180 if (current ==
'\n')
8182 ++position.lines_read;
8183 position.chars_read_current_line = 0;
8201 --position.chars_read_total;
8204 if (position.chars_read_current_line == 0)
8206 if (position.lines_read > 0)
8208 --position.lines_read;
8213 --position.chars_read_current_line;
8219 token_string.pop_back();
8224 void add(char_int_type c)
8226 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8237 return value_integer;
8243 return value_unsigned;
8255 return token_buffer;
8275 for (
const auto c : token_string)
8277 if (
static_cast<unsigned char>(c) <=
'\x1F')
8280 std::array<char, 9> cs{ {} };
8281 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8282 result += cs.data();
8287 result.push_back(
static_cast<std::string::value_type
>(c));
8298 return error_message;
8314 return get() == 0xBB &&
get() == 0xBF;
8328 }
while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8334 if (position.chars_read_total == 0 && !skip_bom())
8336 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8337 return token_type::parse_error;
8344 while (ignore_comments && current ==
'/')
8346 if (!scan_comment())
8348 return token_type::parse_error;
8359 return token_type::begin_array;
8361 return token_type::end_array;
8363 return token_type::begin_object;
8365 return token_type::end_object;
8367 return token_type::name_separator;
8369 return token_type::value_separator;
8374 std::array<char_type, 4> true_literal = { {
static_cast<char_type
>(
't'),
static_cast<char_type
>(
'r'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'e')} };
8375 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8379 std::array<char_type, 5> false_literal = { {
static_cast<char_type
>(
'f'),
static_cast<char_type
>(
'a'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
's'),
static_cast<char_type
>(
'e')} };
8380 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8384 std::array<char_type, 4> null_literal = { {
static_cast<char_type
>(
'n'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
'l')} };
8385 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8390 return scan_string();
8404 return scan_number();
8409 case std::char_traits<char_type>::eof():
8410 return token_type::end_of_input;
8414 error_message =
"invalid literal";
8415 return token_type::parse_error;
8421 InputAdapterType ia;
8424 const bool ignore_comments =
false;
8427 char_int_type current = std::char_traits<char_type>::eof();
8430 bool next_unget =
false;
8436 std::vector<char_type> token_string{};
8439 string_t token_buffer{};
8442 const char* error_message =
"";
8445 number_integer_t value_integer = 0;
8446 number_unsigned_t value_unsigned = 0;
8447 number_float_t value_float = 0;
8450 const char_int_type decimal_point_char =
'.';
8473 template<
typename T>
8476 template<
typename T>
8478 decltype(std::declval<T&>().boolean(std::declval<bool>()));
8480 template<
typename T,
typename Integer>
8482 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
8484 template<
typename T,
typename Un
signed>
8486 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
8488 template<
typename T,
typename Float,
typename String>
8490 std::declval<Float>(), std::declval<const String&>()));
8492 template<
typename T,
typename String>
8494 decltype(std::declval<T&>().string(std::declval<String&>()));
8496 template<
typename T,
typename Binary>
8498 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
8500 template<
typename T>
8502 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8504 template<
typename T,
typename String>
8506 decltype(std::declval<T&>().key(std::declval<String&>()));
8508 template<
typename T>
8511 template<
typename T>
8513 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8515 template<
typename T>
8518 template<
typename T,
typename Exception>
8520 std::declval<std::size_t>(), std::declval<const std::string&>(),
8521 std::declval<const Exception&>()));
8523 template<
typename SAX,
typename BasicJsonType>
8528 "BasicJsonType must be of type basic_json<...>");
8530 using number_integer_t =
typename BasicJsonType::number_integer_t;
8531 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
8532 using number_float_t =
typename BasicJsonType::number_float_t;
8533 using string_t =
typename BasicJsonType::string_t;
8534 using binary_t =
typename BasicJsonType::binary_t;
8535 using exception_t =
typename BasicJsonType::exception;
8554 template<
typename SAX,
typename BasicJsonType>
8559 "BasicJsonType must be of type basic_json<...>");
8561 using number_integer_t =
typename BasicJsonType::number_integer_t;
8562 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
8563 using number_float_t =
typename BasicJsonType::number_float_t;
8564 using string_t =
typename BasicJsonType::string_t;
8565 using binary_t =
typename BasicJsonType::binary_t;
8566 using exception_t =
typename BasicJsonType::exception;
8570 "Missing/invalid function: bool null()");
8572 "Missing/invalid function: bool boolean(bool)");
8574 "Missing/invalid function: bool boolean(bool)");
8577 number_integer_t>::value,
8578 "Missing/invalid function: bool number_integer(number_integer_t)");
8581 number_unsigned_t>::value,
8582 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
8584 number_float_t, string_t>::value,
8585 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
8588 "Missing/invalid function: bool string(string_t&)");
8591 "Missing/invalid function: bool binary(binary_t&)");
8593 "Missing/invalid function: bool start_object(std::size_t)");
8595 "Missing/invalid function: bool key(string_t&)");
8597 "Missing/invalid function: bool end_object()");
8599 "Missing/invalid function: bool start_array(std::size_t)");
8601 "Missing/invalid function: bool end_array()");
8604 "Missing/invalid function: bool parse_error(std::size_t, const "
8605 "std::string&, const exception&)");
8637 static inline bool little_endianness(
int num = 1) noexcept
8639 return *
reinterpret_cast<char*
>(&num) == 1;
8650 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
8653 using number_integer_t =
typename BasicJsonType::number_integer_t;
8654 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
8655 using number_float_t =
typename BasicJsonType::number_float_t;
8656 using string_t =
typename BasicJsonType::string_t;
8657 using binary_t =
typename BasicJsonType::binary_t;
8658 using json_sax_t = SAX;
8659 using char_type =
typename InputAdapterType::char_type;
8660 using char_int_type =
typename std::char_traits<char_type>::int_type;
8691 const
bool strict = true,
8695 bool result =
false;
8700 result = parse_bson_internal();
8704 result = parse_cbor_internal(
true, tag_handler);
8708 result = parse_msgpack_internal();
8713 result = parse_ubjson_internal();
8735 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
8736 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
8752 bool parse_bson_internal()
8754 std::int32_t document_size{};
8767 return sax->end_object();
8777 bool get_bson_cstr(string_t& result)
8779 auto out = std::back_inserter(result);
8787 if (current == 0x00)
8791 *out++ =
static_cast<typename string_t::value_type
>(current);
8806 template<
typename NumberType>
8807 bool get_bson_string(
const NumberType len, string_t& result)
8811 auto last_token = get_token_string();
8816 return get_string(
input_format_t::bson, len -
static_cast<NumberType
>(1), result) && get() != std::char_traits<char_type>::eof();
8828 template<
typename NumberType>
8829 bool get_bson_binary(
const NumberType len, binary_t& result)
8833 auto last_token = get_token_string();
8839 std::uint8_t subtype{};
8841 result.set_subtype(subtype);
8856 bool parse_bson_element_internal(
const char_int_type element_type,
8857 const std::size_t element_type_parse_position)
8859 switch (element_type)
8864 return get_number<double, true>(
input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
8871 return get_number<std::int32_t, true>(
input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
8876 return parse_bson_internal();
8881 return parse_bson_array();
8888 return get_number<std::int32_t, true>(
input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
8893 return sax->boolean(get() != 0);
8903 std::int32_t
value{};
8904 return get_number<std::int32_t, true>(
input_format_t::bson, value) && sax->number_integer(value);
8909 std::int64_t
value{};
8910 return get_number<std::int64_t, true>(
input_format_t::bson, value) && sax->number_integer(value);
8915 std::array<char, 3> cr{ {} };
8916 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
8917 std::string cr_str{ cr.data() };
8918 return sax->parse_error(element_type_parse_position, cr_str,
8936 bool parse_bson_element_list(
const bool is_array)
8940 while (
auto element_type = get())
8947 const std::size_t element_type_parse_position = chars_read;
8953 if (!is_array && !sax->key(key))
8958 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
8974 bool parse_bson_array()
8976 std::int32_t document_size{};
8989 return sax->end_array();
9004 bool parse_cbor_internal(
const bool get_char,
9007 switch (get_char ? get() : current)
9010 case std::char_traits<char_type>::eof():
9038 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
9042 std::uint8_t number{};
9048 std::uint16_t number{};
9054 std::uint32_t number{};
9060 std::uint64_t number{};
9089 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
9093 std::uint8_t number{};
9094 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9099 std::uint16_t number{};
9100 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9105 std::uint32_t number{};
9106 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9111 std::uint64_t number{};
9112 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
9113 -
static_cast<number_integer_t
>(number));
9148 return get_cbor_binary(b) && sax->binary(b);
9183 return get_cbor_string(s) && sax->string(s);
9211 return get_cbor_array(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9216 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9221 std::uint16_t len{};
9222 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9227 std::uint32_t len{};
9228 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9233 std::uint64_t len{};
9234 return get_number(
input_format_t::cbor, len) && get_cbor_array(detail::conditional_static_cast<std::size_t>(len), tag_handler);
9238 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9265 return get_cbor_object(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9270 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9275 std::uint16_t len{};
9276 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9281 std::uint32_t len{};
9282 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9287 std::uint64_t len{};
9288 return get_number(
input_format_t::cbor, len) && get_cbor_object(detail::conditional_static_cast<std::size_t>(len), tag_handler);
9292 return get_cbor_object(
static_cast<std::size_t
>(-1), tag_handler);
9314 switch (tag_handler)
9318 auto last_token = get_token_string();
9330 std::uint8_t subtype_to_ignore{};
9336 std::uint16_t subtype_to_ignore{};
9342 std::uint32_t subtype_to_ignore{};
9348 std::uint64_t subtype_to_ignore{};
9355 return parse_cbor_internal(
true, tag_handler);
9366 std::uint8_t subtype{};
9368 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9373 std::uint16_t subtype{};
9375 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9380 std::uint32_t subtype{};
9382 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9387 std::uint64_t subtype{};
9389 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9393 return parse_cbor_internal(
true, tag_handler);
9396 return get_cbor_binary(b) && sax->binary(b);
9406 return sax->boolean(
false);
9409 return sax->boolean(
true);
9416 const auto byte1_raw = get();
9421 const auto byte2_raw = get();
9427 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9428 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9438 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9439 const double val = [&half]
9441 const int exp = (half >> 10u) & 0x1Fu;
9442 const unsigned int mant = half & 0x3FFu;
9448 return std::ldexp(mant, -24);
9451 ? std::numeric_limits<double>::infinity()
9452 :
std::numeric_limits<double>::quiet_NaN();
9454 return std::ldexp(mant + 1024, exp - 25);
9457 return sax->number_float((half & 0x8000u) != 0
9458 ?
static_cast<number_float_t
>(-val)
9459 :
static_cast<number_float_t
>(val),
"");
9465 return get_number(
input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9471 return get_number(
input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9476 auto last_token = get_token_string();
9494 bool get_cbor_string(string_t& result)
9540 std::uint16_t len{};
9546 std::uint32_t len{};
9552 std::uint64_t len{};
9558 while (get() != 0xFF)
9561 if (!get_cbor_string(chunk))
9565 result.append(chunk);
9572 auto last_token = get_token_string();
9574 exception_message(
input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
9590 bool get_cbor_binary(binary_t& result)
9637 std::uint16_t len{};
9644 std::uint32_t len{};
9651 std::uint64_t len{};
9658 while (get() != 0xFF)
9661 if (!get_cbor_binary(chunk))
9665 result.insert(result.end(), chunk.begin(), chunk.end());
9672 auto last_token = get_token_string();
9674 exception_message(
input_format_t::cbor,
concat(
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token),
"binary"),
nullptr));
9685 bool get_cbor_array(
const std::size_t len,
9693 if (len !=
static_cast<std::size_t
>(-1))
9695 for (std::size_t i = 0; i < len; ++i)
9705 while (get() != 0xFF)
9714 return sax->end_array();
9723 bool get_cbor_object(
const std::size_t len,
9734 if (len !=
static_cast<std::size_t
>(-1))
9736 for (std::size_t i = 0; i < len; ++i)
9753 while (get() != 0xFF)
9769 return sax->end_object();
9779 bool parse_msgpack_internal()
9784 case std::char_traits<char_type>::eof():
9916 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
9935 return get_msgpack_object(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x0Fu));
9954 return get_msgpack_array(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x0Fu));
9994 return get_msgpack_string(s) && sax->string(s);
10001 return sax->boolean(
false);
10004 return sax->boolean(
true);
10019 return get_msgpack_binary(b) && sax->binary(b);
10025 return get_number(
input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10031 return get_number(
input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10036 std::uint8_t number{};
10042 std::uint16_t number{};
10048 std::uint32_t number{};
10054 std::uint64_t number{};
10060 std::int8_t number{};
10066 std::int16_t number{};
10072 std::int32_t number{};
10078 std::int64_t number{};
10084 std::uint16_t len{};
10090 std::uint32_t len{};
10096 std::uint16_t len{};
10102 std::uint32_t len{};
10139 return sax->number_integer(
static_cast<std::int8_t
>(current));
10143 auto last_token = get_token_string();
10160 bool get_msgpack_string(string_t& result)
10208 std::uint8_t len{};
10214 std::uint16_t len{};
10220 std::uint32_t len{};
10226 auto last_token = get_token_string();
10228 exception_message(
input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10243 bool get_msgpack_binary(binary_t& result)
10246 auto assign_and_return_true = [&result](std::int8_t subtype)
10248 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10256 std::uint8_t len{};
10263 std::uint16_t len{};
10270 std::uint32_t len{};
10277 std::uint8_t len{};
10278 std::int8_t subtype{};
10282 assign_and_return_true(subtype);
10287 std::uint16_t len{};
10288 std::int8_t subtype{};
10292 assign_and_return_true(subtype);
10297 std::uint32_t len{};
10298 std::int8_t subtype{};
10302 assign_and_return_true(subtype);
10307 std::int8_t subtype{};
10310 assign_and_return_true(subtype);
10315 std::int8_t subtype{};
10318 assign_and_return_true(subtype);
10323 std::int8_t subtype{};
10326 assign_and_return_true(subtype);
10331 std::int8_t subtype{};
10334 assign_and_return_true(subtype);
10339 std::int8_t subtype{};
10342 assign_and_return_true(subtype);
10354 bool get_msgpack_array(
const std::size_t len)
10361 for (std::size_t i = 0; i < len; ++i)
10369 return sax->end_array();
10376 bool get_msgpack_object(
const std::size_t len)
10384 for (std::size_t i = 0; i < len; ++i)
10399 return sax->end_object();
10413 bool parse_ubjson_internal(
const bool get_char =
true)
10415 return get_ubjson_value(get_char ? get_ignore_noop() : current);
10432 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
10448 std::uint8_t len{};
10449 return get_number(input_format, len) && get_string(input_format, len, result);
10455 return get_number(input_format, len) && get_string(input_format, len, result);
10460 std::int16_t len{};
10461 return get_number(input_format, len) && get_string(input_format, len, result);
10466 std::int32_t len{};
10467 return get_number(input_format, len) && get_string(input_format, len, result);
10472 std::int64_t len{};
10473 return get_number(input_format, len) && get_string(input_format, len, result);
10482 std::uint16_t len{};
10483 return get_number(input_format, len) && get_string(input_format, len, result);
10492 std::uint32_t len{};
10493 return get_number(input_format, len) && get_string(input_format, len, result);
10502 std::uint64_t len{};
10503 return get_number(input_format, len) && get_string(input_format, len, result);
10509 auto last_token = get_token_string();
10510 std::string message;
10514 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
10518 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
10520 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
10527 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
10529 std::pair<std::size_t, char_int_type> size_and_type;
10531 bool inside_ndarray =
true;
10538 if (size_and_type.first != string_t::npos)
10540 if (size_and_type.second != 0)
10542 if (size_and_type.second !=
'N')
10544 for (std::size_t i = 0; i < size_and_type.first; ++i)
10546 if (
JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, inside_ndarray, size_and_type.second)))
10550 dim.push_back(dimlen);
10556 for (std::size_t i = 0; i < size_and_type.first; ++i)
10562 dim.push_back(dimlen);
10568 while (current !=
']')
10574 dim.push_back(dimlen);
10588 bool get_ubjson_size_value(std::size_t& result,
bool& inside_ndarray, char_int_type prefix = 0)
10592 prefix = get_ignore_noop();
10599 std::uint8_t number{};
10604 result =
static_cast<std::size_t
>(number);
10610 std::int8_t number{};
10617 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
10618 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
10620 result =
static_cast<std::size_t
>(number);
10626 std::int16_t number{};
10633 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
10634 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
10636 result =
static_cast<std::size_t
>(number);
10642 std::int32_t number{};
10649 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
10650 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
10652 result =
static_cast<std::size_t
>(number);
10658 std::int64_t number{};
10665 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
10666 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
10668 result =
static_cast<std::size_t
>(number);
10678 std::uint16_t number{};
10683 result =
static_cast<std::size_t
>(number);
10693 std::uint32_t number{};
10698 result =
static_cast<std::size_t
>(number);
10708 std::uint64_t number{};
10713 result = detail::conditional_static_cast<std::size_t>(number);
10723 if (inside_ndarray)
10725 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimention vector can only contain integers",
"size"),
nullptr));
10727 std::vector<size_t> dim;
10732 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
10734 result = dim.at(dim.size() - 1);
10748 string_t
key =
"_ArraySize_";
10749 if (
JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size())))
10762 inside_ndarray =
true;
10763 return sax->end_array();
10772 auto last_token = get_token_string();
10773 std::string message;
10777 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
10781 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
10783 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
10797 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result,
bool inside_ndarray =
false)
10799 result.first = string_t::npos;
10801 bool is_ndarray =
false;
10805 if (current ==
'$')
10807 std::vector<char_int_type> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z' };
10809 result.second = get();
10812 auto last_token = get_token_string();
10814 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
10829 auto last_token = get_token_string();
10831 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
10834 bool is_error = get_ubjson_size_value(result.first, is_ndarray);
10837 if (inside_ndarray)
10839 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
10840 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
10842 result.second |= (1 << 8);
10847 if (current ==
'#')
10849 bool is_error = get_ubjson_size_value(result.first, is_ndarray);
10852 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
10853 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
10865 bool get_ubjson_value(
const char_int_type prefix)
10869 case std::char_traits<char_type>::eof():
10870 return unexpect_eof(input_format,
"value");
10873 return sax->boolean(
true);
10875 return sax->boolean(
false);
10878 return sax->null();
10882 std::uint8_t number{};
10883 return get_number(input_format, number) && sax->number_unsigned(number);
10888 std::int8_t number{};
10889 return get_number(input_format, number) && sax->number_integer(number);
10894 std::int16_t number{};
10895 return get_number(input_format, number) && sax->number_integer(number);
10900 std::int32_t number{};
10901 return get_number(input_format, number) && sax->number_integer(number);
10906 std::int64_t number{};
10907 return get_number(input_format, number) && sax->number_integer(number);
10916 std::uint16_t number{};
10917 return get_number(input_format, number) && sax->number_unsigned(number);
10926 std::uint32_t number{};
10927 return get_number(input_format, number) && sax->number_unsigned(number);
10936 std::uint64_t number{};
10937 return get_number(input_format, number) && sax->number_unsigned(number);
10946 const auto byte1_raw = get();
10951 const auto byte2_raw = get();
10957 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10958 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10968 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
10969 const double val = [&half]
10971 const int exp = (half >> 10u) & 0x1Fu;
10972 const unsigned int mant = half & 0x3FFu;
10978 return std::ldexp(mant, -24);
10981 ? std::numeric_limits<double>::infinity()
10982 :
std::numeric_limits<double>::quiet_NaN();
10984 return std::ldexp(mant + 1024, exp - 25);
10987 return sax->number_float((half & 0x8000u) != 0
10988 ?
static_cast<number_float_t
>(-val)
10989 :
static_cast<number_float_t
>(val),
"");
10995 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11001 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11006 return get_ubjson_high_precision_number();
11018 auto last_token = get_token_string();
11020 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
11022 string_t s(1,
static_cast<typename string_t::value_type
>(current));
11023 return sax->string(s);
11029 return get_ubjson_string(s) && sax->string(s);
11033 return get_ubjson_array();
11036 return get_ubjson_object();
11041 auto last_token = get_token_string();
11042 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format,
"invalid byte: 0x" + last_token,
"value"),
nullptr));
11048 bool get_ubjson_array()
11050 std::pair<std::size_t, char_int_type> size_and_type;
11059 if (input_format ==
input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
11061 std::map<char_int_type, string_t> bjdtype = { {
'U',
"uint8"}, {
'i',
"int8"}, {
'u',
"uint16"}, {
'I',
"int16"},
11062 {
'm',
"uint32"}, {
'l',
"int32"}, {
'M',
"uint64"}, {
'L',
"int64"}, {
'd',
"single"}, {
'D',
"double"}, {
'C',
"char"}
11065 size_and_type.second &= ~(
static_cast<char_int_type
>(1) << 8);
11067 string_t
key =
"_ArrayType_";
11070 auto last_token = get_token_string();
11072 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
11080 if (size_and_type.second ==
'C')
11082 size_and_type.second =
'U';
11085 key =
"_ArrayData_";
11091 for (std::size_t i = 0; i < size_and_type.first; ++i)
11099 return (sax->end_array() && sax->end_object());
11102 if (size_and_type.first != string_t::npos)
11109 if (size_and_type.second != 0)
11111 if (size_and_type.second !=
'N')
11113 for (std::size_t i = 0; i < size_and_type.first; ++i)
11124 for (std::size_t i = 0; i < size_and_type.first; ++i)
11140 while (current !=
']')
11150 return sax->end_array();
11156 bool get_ubjson_object()
11158 std::pair<std::size_t, char_int_type> size_and_type;
11165 if (input_format ==
input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
11167 auto last_token = get_token_string();
11169 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11173 if (size_and_type.first != string_t::npos)
11180 if (size_and_type.second != 0)
11182 for (std::size_t i = 0; i < size_and_type.first; ++i)
11197 for (std::size_t i = 0; i < size_and_type.first; ++i)
11218 while (current !=
'}')
11233 return sax->end_object();
11239 bool get_ubjson_high_precision_number()
11242 std::size_t size{};
11243 bool inside_ndarray =
false;
11244 auto res = get_ubjson_size_value(size, inside_ndarray);
11251 std::vector<char> number_vector;
11252 for (std::size_t i = 0; i < size; ++i)
11259 number_vector.push_back(
static_cast<char>(current));
11264 auto number_lexer = detail::lexer<BasicJsonType, ia_type>(
detail::input_adapter(number_vector),
false);
11265 const auto result_number = number_lexer.scan();
11266 const auto number_string = number_lexer.get_token_string();
11267 const auto result_remainder = number_lexer.scan();
11274 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11277 switch (result_number)
11279 case token_type::value_integer:
11280 return sax->number_integer(number_lexer.get_number_integer());
11281 case token_type::value_unsigned:
11282 return sax->number_unsigned(number_lexer.get_number_unsigned());
11283 case token_type::value_float:
11284 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
11285 case token_type::uninitialized:
11286 case token_type::literal_true:
11287 case token_type::literal_false:
11288 case token_type::literal_null:
11289 case token_type::value_string:
11290 case token_type::begin_array:
11291 case token_type::begin_object:
11292 case token_type::end_array:
11293 case token_type::end_object:
11294 case token_type::name_separator:
11295 case token_type::value_separator:
11296 case token_type::parse_error:
11297 case token_type::end_of_input:
11298 case token_type::literal_or_value:
11301 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11318 char_int_type get()
11321 return current = ia.get_character();
11327 char_int_type get_ignore_noop()
11332 }
while (current ==
'N');
11352 template<
typename NumberType,
bool InputIsLittleEndian = false>
11353 bool get_number(
const input_format_t format, NumberType& result)
11356 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
11357 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
11368 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(current);
11372 vec[i] =
static_cast<std::uint8_t
>(current);
11377 std::memcpy(&result, vec.data(),
sizeof(NumberType));
11395 template<
typename NumberType>
11397 const NumberType len,
11400 bool success =
true;
11401 for (NumberType i = 0; i < len; i++)
11409 result.push_back(
static_cast<typename string_t::value_type
>(current));
11428 template<
typename NumberType>
11430 const NumberType len,
11433 bool success =
true;
11434 for (NumberType i = 0; i < len; i++)
11442 result.push_back(
static_cast<std::uint8_t
>(current));
11453 bool unexpect_eof(const
input_format_t format, const
char* context)
const
11457 return sax->parse_error(chars_read,
"<end of file>",
11458 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
11466 std::string get_token_string()
const
11468 std::array<char, 3> cr{ {} };
11469 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
11470 return std::string{ cr.data() };
11480 const std::string& detail,
11481 const std::string& context)
const
11483 std::string error_msg =
"syntax error while parsing ";
11488 error_msg +=
"CBOR";
11492 error_msg +=
"MessagePack";
11496 error_msg +=
"UBJSON";
11500 error_msg +=
"BSON";
11504 error_msg +=
"BJData";
11512 return concat(error_msg,
' ', context,
": ", detail);
11517 InputAdapterType ia;
11520 char_int_type current = std::char_traits<char_type>::eof();
11523 std::size_t chars_read = 0;
11526 const bool is_little_endian = little_endianness();
11532 json_sax_t* sax =
nullptr;
11546#include <functional>
11592 template<
typename BasicJsonType>
11594 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
11601 template<
typename BasicJsonType,
typename InputAdapterType>
11604 using number_integer_t =
typename BasicJsonType::number_integer_t;
11605 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
11606 using number_float_t =
typename BasicJsonType::number_float_t;
11607 using string_t =
typename BasicJsonType::string_t;
11615 const bool allow_exceptions_ =
true,
11616 const bool skip_comments =
false)
11618 , m_lexer(
std::move(adapter), skip_comments)
11619 , allow_exceptions(allow_exceptions_)
11635 void parse(
const bool strict, BasicJsonType& result)
11640 sax_parse_internal(&sdp);
11643 if (
strict && (get_token() != token_type::end_of_input))
11648 exception_message(token_type::end_of_input,
"value"),
nullptr));
11660 if (result.is_discarded())
11668 sax_parse_internal(&sdp);
11671 if (
strict && (get_token() != token_type::end_of_input))
11686 result.assert_invariant();
11701 template<
typename SAX>
11706 const bool result = sax_parse_internal(sax);
11709 if (result &&
strict && (get_token() != token_type::end_of_input))
11720 template<
typename SAX>
11722 bool sax_parse_internal(SAX* sax)
11726 std::vector<bool> states;
11728 bool skip_to_state_evaluation =
false;
11732 if (!skip_to_state_evaluation)
11735 switch (last_token)
11737 case token_type::begin_object:
11745 if (get_token() == token_type::end_object)
11775 states.push_back(
false);
11782 case token_type::begin_array:
11790 if (get_token() == token_type::end_array)
11800 states.push_back(
true);
11806 case token_type::value_float:
11825 case token_type::literal_false:
11834 case token_type::literal_null:
11843 case token_type::literal_true:
11852 case token_type::value_integer:
11861 case token_type::value_string:
11870 case token_type::value_unsigned:
11879 case token_type::parse_error:
11887 case token_type::uninitialized:
11888 case token_type::end_array:
11889 case token_type::end_object:
11890 case token_type::name_separator:
11891 case token_type::value_separator:
11892 case token_type::end_of_input:
11893 case token_type::literal_or_value:
11904 skip_to_state_evaluation =
false;
11908 if (states.empty())
11917 if (get_token() == token_type::value_separator)
11938 skip_to_state_evaluation =
true;
11950 if (get_token() == token_type::value_separator)
11992 skip_to_state_evaluation =
true;
12003 token_type get_token()
12005 return last_token = m_lexer.
scan();
12008 std::string exception_message(
const token_type expected,
const std::string& context)
12010 std::string error_msg =
"syntax error ";
12012 if (!context.empty())
12014 error_msg +=
concat(
"while parsing ", context,
' ');
12019 if (last_token == token_type::parse_error)
12029 if (expected != token_type::uninitialized)
12039 const parser_callback_t<BasicJsonType> callback =
nullptr;
12041 token_type last_token = token_type::uninitialized;
12045 const bool allow_exceptions =
true;
12079 using difference_type = std::ptrdiff_t;
12080 static constexpr difference_type begin_value = 0;
12081 static constexpr difference_type end_value = begin_value + 1;
12085 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
12096 m_it = begin_value;
12108 return m_it == begin_value;
12114 return m_it == end_value;
12119 return lhs.m_it == rhs.m_it;
12124 return lhs.m_it < rhs.m_it;
12129 auto result = *
this;
12136 return lhs.m_it - rhs.m_it;
12147 auto result = *
this;
12160 auto result = *
this;
12207#include <type_traits>
12229 template<
typename IteratorType>
class iteration_proxy;
12230 template<
typename IteratorType>
class iteration_proxy_value;
12248 template<
typename BasicJsonType>
12255 friend BasicJsonType;
12259 using object_t =
typename BasicJsonType::object_t;
12260 using array_t =
typename BasicJsonType::array_t;
12263 "iter_impl only accepts (const) basic_json");
12265 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
12266 && std::is_base_of<std::bidirectional_iterator_tag, typename array_t::iterator::iterator_category>::value,
12267 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
12282 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
12283 typename BasicJsonType::const_pointer,
12284 typename BasicJsonType::pointer>::type;
12287 typename std::conditional<std::is_const<BasicJsonType>::value,
12288 typename BasicJsonType::const_reference,
12289 typename BasicJsonType::reference>::type;
12306 switch (m_object->m_type)
12353 : m_object(other.m_object),
m_it(other.m_it)
12364 if (&other !=
this)
12366 m_object = other.m_object;
12378 : m_object(other.m_object),
m_it(other.m_it)
12389 m_object = other.m_object;
12399 void set_begin() noexcept
12403 switch (m_object->m_type)
12447 switch (m_object->m_type)
12486 switch (m_object->m_type)
12530 switch (m_object->m_type)
12570 auto result = *
this;
12583 switch (m_object->m_type)
12621 auto result = *
this;
12634 switch (m_object->m_type)
12670 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
12681 switch (m_object->m_type)
12706 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
12726 switch (m_object->m_type)
12753 return !other.operator < (*this);
12782 switch (m_object->m_type)
12826 auto result = *
this;
12848 auto result = *
this;
12861 switch (m_object->m_type)
12890 switch (m_object->m_type)
12924 const typename object_t::key_type&
key()
const
12989 template<
typename Base>
13063 auto it = --this->base();
13070 auto it = --this->base();
13071 return it.operator * ();
13082#include <algorithm>
13108 template<
typename RefStringType>
13118 template<
typename T>
13119 struct string_t_helper
13127 using type = StringType;
13132 using string_t =
typename string_t_helper<RefStringType>::type;
13137 : reference_tokens(split(s))
13144 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
13148 return detail::concat(a,
'/', detail::escape(b));
13163 reference_tokens.insert(reference_tokens.end(),
13164 ptr.reference_tokens.begin(),
13165 ptr.reference_tokens.end());
13229 reference_tokens.pop_back();
13241 return reference_tokens.back();
13248 reference_tokens.push_back(token);
13255 reference_tokens.push_back(std::move(token));
13262 return reference_tokens.empty();
13276 template<
typename BasicJsonType>
13277 static typename BasicJsonType::size_type array_index(
const string_t& s)
13279 using size_type =
typename BasicJsonType::size_type;
13293 const char* p = s.c_str();
13294 char* p_end =
nullptr;
13296 unsigned long long res = std::strtoull(p, &p_end, 10);
13306 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
13311 return static_cast<size_type
>(res);
13323 result.reference_tokens = { reference_tokens[0] };
13336 template<
typename BasicJsonType>
13337 BasicJsonType& get_and_create(BasicJsonType& j)
const
13343 for (
const auto& reference_token : reference_tokens)
13345 switch (result->type())
13349 if (reference_token ==
"0")
13352 result = &result->operator[](0);
13357 result = &result->operator[](reference_token);
13365 result = &result->operator[](reference_token);
13372 result = &result->operator[](array_index<BasicJsonType>(reference_token));
13416 template<
typename BasicJsonType>
13417 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
13419 for (
const auto& reference_token : reference_tokens)
13422 if (ptr->is_null())
13426 std::all_of(reference_token.begin(), reference_token.end(),
13427 [](
const unsigned char x)
13429 return std::isdigit(x);
13433 *ptr = (nums || reference_token ==
"-")
13438 switch (ptr->type())
13443 ptr = &ptr->operator[](reference_token);
13449 if (reference_token ==
"-")
13452 ptr = &ptr->operator[](ptr->m_value.array->size());
13457 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
13484 template<
typename BasicJsonType>
13485 BasicJsonType& get_checked(BasicJsonType* ptr)
const
13487 for (
const auto& reference_token : reference_tokens)
13489 switch (ptr->type())
13494 ptr = &ptr->at(reference_token);
13504 "array index '-' (",
std::to_string(ptr->m_value.array->size()),
13505 ") is out of range"), ptr));
13509 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
13542 template<
typename BasicJsonType>
13543 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
13545 for (
const auto& reference_token : reference_tokens)
13547 switch (ptr->type())
13552 ptr = &ptr->operator[](reference_token);
13565 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
13591 template<
typename BasicJsonType>
13592 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
13594 for (
const auto& reference_token : reference_tokens)
13596 switch (ptr->type())
13601 ptr = &ptr->at(reference_token);
13611 "array index '-' (",
std::to_string(ptr->m_value.array->size()),
13612 ") is out of range"), ptr));
13616 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
13640 template<
typename BasicJsonType>
13641 bool contains(
const BasicJsonType* ptr)
const
13643 for (
const auto& reference_token : reference_tokens)
13645 switch (ptr->type())
13649 if (!ptr->contains(reference_token))
13655 ptr = &ptr->operator[](reference_token);
13666 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
13678 for (std::size_t i = 1; i < reference_token.size(); i++)
13688 const auto idx = array_index<BasicJsonType>(reference_token);
13689 if (idx >= ptr->size())
13695 ptr = &ptr->operator[](idx);
13729 static std::vector<string_t> split(
const string_t& reference_string)
13731 std::vector<string_t> result;
13734 if (reference_string.empty())
13750 std::size_t slash = reference_string.find_first_of(
'/', 1),
13757 start = (slash == string_t::npos) ? 0 : slash + 1,
13759 slash = reference_string.find_first_of(
'/', start))
13763 auto reference_token = reference_string.substr(start, slash - start);
13766 for (std::size_t pos = reference_token.find_first_of(
'~');
13767 pos != string_t::npos;
13768 pos = reference_token.find_first_of(
'~', pos + 1))
13774 (reference_token[pos + 1] !=
'0' &&
13775 reference_token[pos + 1] !=
'1')))
13782 detail::unescape(reference_token);
13783 result.push_back(reference_token);
13797 template<
typename BasicJsonType>
13798 static void flatten(
const string_t& reference_string,
13799 const BasicJsonType& value,
13800 BasicJsonType& result)
13802 switch (
value.type())
13806 if (
value.m_value.array->empty())
13809 result[reference_string] =
nullptr;
13814 for (std::size_t i = 0; i <
value.m_value.array->size(); ++i)
13817 value.m_value.array->operator[](i), result);
13825 if (
value.m_value.object->empty())
13828 result[reference_string] =
nullptr;
13833 for (
const auto& element : *
value.m_value.object)
13852 result[reference_string] =
value;
13868 template<
typename BasicJsonType>
13869 static BasicJsonType
13870 unflatten(
const BasicJsonType& value)
13877 BasicJsonType result;
13880 for (
const auto& element : *
value.m_value.object)
13891 json_pointer(element.first).get_and_create(result) = element.second;
13898 json_pointer<string_t> convert() const&
13900 json_pointer<string_t> result;
13901 result.reference_tokens = reference_tokens;
13905 json_pointer<string_t> convert()&&
13907 json_pointer<string_t> result;
13908 result.reference_tokens = std::move(reference_tokens);
13923 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
13925 friend bool operator==(json_pointer<RefStringTypeLhs>
const& lhs,
13926 json_pointer<RefStringTypeRhs>
const& rhs)
noexcept;
13939 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
13941 friend bool operator!=(json_pointer<RefStringTypeLhs>
const& lhs,
13942 json_pointer<RefStringTypeRhs>
const& rhs)
noexcept;
13945 std::vector<string_t> reference_tokens;
13949 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
13953 return lhs.reference_tokens == rhs.reference_tokens;
13956 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
13960 return !(lhs == rhs);
13967#include <initializer_list>
13977 template<
typename BasicJsonType>
13988 : value_ref(&
value)
13992 : owned_value(
init)
13999 : owned_value(
std::forward<Args>(args)...)
14011 if (value_ref ==
nullptr)
14013 return std::move(owned_value);
14020 return value_ref ? *value_ref : owned_value;
14048#include <algorithm>
14066#include <algorithm>
14100 template<typename CharType>
14104 template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
14118 void write_characters(const CharType* s,
std::
size_t length)
override
14120 std::copy(s, s + length, std::back_inserter(v));
14124 std::vector<CharType, AllocatorType>& v;
14129 template<
typename CharType>
14143 void write_characters(const CharType* s,
std::
size_t length)
override
14145 stream.write(s,
static_cast<std::streamsize
>(length));
14149 std::basic_ostream<CharType>& stream;
14154 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14168 void write_characters(const CharType* s,
std::
size_t length)
override
14170 str.append(s, length);
14177 template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14181 template<
typename AllocatorType = std::allocator<CharType>>
14218 template<
typename BasicJsonType,
typename CharType>
14221 using string_t =
typename BasicJsonType::string_t;
14222 using binary_t =
typename BasicJsonType::binary_t;
14223 using number_float_t =
typename BasicJsonType::number_float_t;
14244 case value_t::object:
14246 write_bson_object(*j.m_value.object);
14250 case value_t::null:
14251 case value_t::array:
14252 case value_t::string:
14253 case value_t::boolean:
14254 case value_t::number_integer:
14255 case value_t::number_unsigned:
14256 case value_t::number_float:
14257 case value_t::binary:
14258 case value_t::discarded:
14261 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
14273 case value_t::null:
14275 oa->write_character(to_char_type(0xF6));
14279 case value_t::boolean:
14281 oa->write_character(j.m_value.boolean
14282 ? to_char_type(0xF5)
14283 : to_char_type(0xF4));
14287 case value_t::number_integer:
14289 if (j.m_value.number_integer >= 0)
14294 if (j.m_value.number_integer <= 0x17)
14296 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14298 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
14300 oa->write_character(to_char_type(0x18));
14301 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14303 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
14305 oa->write_character(to_char_type(0x19));
14306 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14308 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
14310 oa->write_character(to_char_type(0x1A));
14311 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14315 oa->write_character(to_char_type(0x1B));
14316 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14323 const auto positive_number = -1 - j.m_value.number_integer;
14324 if (j.m_value.number_integer >= -24)
14326 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
14328 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
14330 oa->write_character(to_char_type(0x38));
14331 write_number(
static_cast<std::uint8_t
>(positive_number));
14333 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
14335 oa->write_character(to_char_type(0x39));
14336 write_number(
static_cast<std::uint16_t
>(positive_number));
14338 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
14340 oa->write_character(to_char_type(0x3A));
14341 write_number(
static_cast<std::uint32_t
>(positive_number));
14345 oa->write_character(to_char_type(0x3B));
14346 write_number(
static_cast<std::uint64_t
>(positive_number));
14352 case value_t::number_unsigned:
14354 if (j.m_value.number_unsigned <= 0x17)
14356 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14358 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14360 oa->write_character(to_char_type(0x18));
14361 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14363 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14365 oa->write_character(to_char_type(0x19));
14366 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
14368 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14370 oa->write_character(to_char_type(0x1A));
14371 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
14375 oa->write_character(to_char_type(0x1B));
14376 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
14381 case value_t::number_float:
14383 if (std::isnan(j.m_value.number_float))
14386 oa->write_character(to_char_type(0xF9));
14387 oa->write_character(to_char_type(0x7E));
14388 oa->write_character(to_char_type(0x00));
14390 else if (std::isinf(j.m_value.number_float))
14393 oa->write_character(to_char_type(0xf9));
14394 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
14395 oa->write_character(to_char_type(0x00));
14399 write_compact_float(j.m_value.number_float, detail::input_format_t::cbor);
14404 case value_t::string:
14407 const auto N = j.m_value.string->size();
14410 write_number(
static_cast<std::uint8_t
>(0x60 + N));
14412 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14414 oa->write_character(to_char_type(0x78));
14415 write_number(
static_cast<std::uint8_t
>(N));
14417 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14419 oa->write_character(to_char_type(0x79));
14420 write_number(
static_cast<std::uint16_t
>(N));
14422 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14424 oa->write_character(to_char_type(0x7A));
14425 write_number(
static_cast<std::uint32_t
>(N));
14428 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14430 oa->write_character(to_char_type(0x7B));
14431 write_number(
static_cast<std::uint64_t
>(N));
14436 oa->write_characters(
14437 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14438 j.m_value.string->size());
14442 case value_t::array:
14445 const auto N = j.m_value.array->size();
14448 write_number(
static_cast<std::uint8_t
>(0x80 + N));
14450 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14452 oa->write_character(to_char_type(0x98));
14453 write_number(
static_cast<std::uint8_t
>(N));
14455 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14457 oa->write_character(to_char_type(0x99));
14458 write_number(
static_cast<std::uint16_t
>(N));
14460 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14462 oa->write_character(to_char_type(0x9A));
14463 write_number(
static_cast<std::uint32_t
>(N));
14466 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14468 oa->write_character(to_char_type(0x9B));
14469 write_number(
static_cast<std::uint64_t
>(N));
14474 for (
const auto& el : *j.m_value.array)
14481 case value_t::binary:
14483 if (j.m_value.binary->has_subtype())
14485 if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
14487 write_number(
static_cast<std::uint8_t
>(0xd8));
14488 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
14490 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
14492 write_number(
static_cast<std::uint8_t
>(0xd9));
14493 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
14495 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
14497 write_number(
static_cast<std::uint8_t
>(0xda));
14498 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
14500 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
14502 write_number(
static_cast<std::uint8_t
>(0xdb));
14503 write_number(
static_cast<std::uint64_t
>(j.m_value.binary->subtype()));
14508 const auto N = j.m_value.binary->size();
14511 write_number(
static_cast<std::uint8_t
>(0x40 + N));
14513 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14515 oa->write_character(to_char_type(0x58));
14516 write_number(
static_cast<std::uint8_t
>(N));
14518 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14520 oa->write_character(to_char_type(0x59));
14521 write_number(
static_cast<std::uint16_t
>(N));
14523 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14525 oa->write_character(to_char_type(0x5A));
14526 write_number(
static_cast<std::uint32_t
>(N));
14529 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14531 oa->write_character(to_char_type(0x5B));
14532 write_number(
static_cast<std::uint64_t
>(N));
14537 oa->write_characters(
14538 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14544 case value_t::object:
14547 const auto N = j.m_value.object->size();
14550 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
14552 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14554 oa->write_character(to_char_type(0xB8));
14555 write_number(
static_cast<std::uint8_t
>(N));
14557 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14559 oa->write_character(to_char_type(0xB9));
14560 write_number(
static_cast<std::uint16_t
>(N));
14562 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14564 oa->write_character(to_char_type(0xBA));
14565 write_number(
static_cast<std::uint32_t
>(N));
14568 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14570 oa->write_character(to_char_type(0xBB));
14571 write_number(
static_cast<std::uint64_t
>(N));
14576 for (
const auto& el : *j.m_value.object)
14578 write_cbor(el.first);
14579 write_cbor(el.second);
14584 case value_t::discarded:
14597 case value_t::null:
14599 oa->write_character(to_char_type(0xC0));
14603 case value_t::boolean:
14605 oa->write_character(j.m_value.boolean
14606 ? to_char_type(0xC3)
14607 : to_char_type(0xC2));
14611 case value_t::number_integer:
14613 if (j.m_value.number_integer >= 0)
14618 if (j.m_value.number_unsigned < 128)
14621 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14623 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14626 oa->write_character(to_char_type(0xCC));
14627 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14629 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14632 oa->write_character(to_char_type(0xCD));
14633 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14635 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14638 oa->write_character(to_char_type(0xCE));
14639 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14641 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
14644 oa->write_character(to_char_type(0xCF));
14645 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14650 if (j.m_value.number_integer >= -32)
14653 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
14655 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
14656 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
14659 oa->write_character(to_char_type(0xD0));
14660 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
14662 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
14663 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
14666 oa->write_character(to_char_type(0xD1));
14667 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
14669 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
14670 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
14673 oa->write_character(to_char_type(0xD2));
14674 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
14676 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
14677 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
14680 oa->write_character(to_char_type(0xD3));
14681 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
14687 case value_t::number_unsigned:
14689 if (j.m_value.number_unsigned < 128)
14692 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14694 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14697 oa->write_character(to_char_type(0xCC));
14698 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14700 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14703 oa->write_character(to_char_type(0xCD));
14704 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14706 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14709 oa->write_character(to_char_type(0xCE));
14710 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14712 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
14715 oa->write_character(to_char_type(0xCF));
14716 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14721 case value_t::number_float:
14723 write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack);
14727 case value_t::string:
14730 const auto N = j.m_value.string->size();
14734 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
14736 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14739 oa->write_character(to_char_type(0xD9));
14740 write_number(
static_cast<std::uint8_t
>(N));
14742 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14745 oa->write_character(to_char_type(0xDA));
14746 write_number(
static_cast<std::uint16_t
>(N));
14748 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14751 oa->write_character(to_char_type(0xDB));
14752 write_number(
static_cast<std::uint32_t
>(N));
14756 oa->write_characters(
14757 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14758 j.m_value.string->size());
14762 case value_t::array:
14765 const auto N = j.m_value.array->size();
14769 write_number(
static_cast<std::uint8_t
>(0x90 | N));
14771 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14774 oa->write_character(to_char_type(0xDC));
14775 write_number(
static_cast<std::uint16_t
>(N));
14777 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14780 oa->write_character(to_char_type(0xDD));
14781 write_number(
static_cast<std::uint32_t
>(N));
14785 for (
const auto& el : *j.m_value.array)
14792 case value_t::binary:
14796 const bool use_ext = j.m_value.binary->has_subtype();
14799 const auto N = j.m_value.binary->size();
14800 if (N <= (std::numeric_limits<std::uint8_t>::max)())
14802 std::uint8_t output_type{};
14809 output_type = 0xD4;
14812 output_type = 0xD5;
14815 output_type = 0xD6;
14818 output_type = 0xD7;
14821 output_type = 0xD8;
14824 output_type = 0xC7;
14832 output_type = 0xC4;
14836 oa->write_character(to_char_type(output_type));
14839 write_number(
static_cast<std::uint8_t
>(N));
14842 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14844 std::uint8_t output_type = use_ext
14848 oa->write_character(to_char_type(output_type));
14849 write_number(
static_cast<std::uint16_t
>(N));
14851 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14853 std::uint8_t output_type = use_ext
14857 oa->write_character(to_char_type(output_type));
14858 write_number(
static_cast<std::uint32_t
>(N));
14864 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
14868 oa->write_characters(
14869 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14875 case value_t::object:
14878 const auto N = j.m_value.object->size();
14882 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
14884 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14887 oa->write_character(to_char_type(0xDE));
14888 write_number(
static_cast<std::uint16_t
>(N));
14890 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14893 oa->write_character(to_char_type(0xDF));
14894 write_number(
static_cast<std::uint32_t
>(N));
14898 for (
const auto& el : *j.m_value.object)
14900 write_msgpack(el.first);
14901 write_msgpack(el.second);
14906 case value_t::discarded:
14920 const bool use_type,
const bool add_prefix =
true,
14921 const bool use_bjdata =
false)
14925 case value_t::null:
14929 oa->write_character(to_char_type(
'Z'));
14934 case value_t::boolean:
14938 oa->write_character(j.m_value.boolean
14939 ? to_char_type(
'T')
14940 : to_char_type(
'F'));
14945 case value_t::number_integer:
14947 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix, use_bjdata);
14951 case value_t::number_unsigned:
14953 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix, use_bjdata);
14957 case value_t::number_float:
14959 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix, use_bjdata);
14963 case value_t::string:
14967 oa->write_character(to_char_type(
'S'));
14969 write_number_with_ubjson_prefix(j.m_value.string->size(),
true, use_bjdata);
14970 oa->write_characters(
14971 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14972 j.m_value.string->size());
14976 case value_t::array:
14980 oa->write_character(to_char_type(
'['));
14983 bool prefix_required =
true;
14984 if (use_type && !j.m_value.array->empty())
14987 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
14988 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
14989 [
this, first_prefix, use_bjdata](
const BasicJsonType& v)
14991 return ubjson_prefix(v, use_bjdata) == first_prefix;
14994 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z' };
14996 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
14998 prefix_required =
false;
14999 oa->write_character(to_char_type(
'$'));
15000 oa->write_character(first_prefix);
15006 oa->write_character(to_char_type(
'#'));
15007 write_number_with_ubjson_prefix(j.m_value.array->size(),
true, use_bjdata);
15010 for (
const auto& el : *j.m_value.array)
15012 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
15017 oa->write_character(to_char_type(
']'));
15023 case value_t::binary:
15027 oa->write_character(to_char_type(
'['));
15030 if (use_type && !j.m_value.binary->empty())
15033 oa->write_character(to_char_type(
'$'));
15034 oa->write_character(
'U');
15039 oa->write_character(to_char_type(
'#'));
15040 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true, use_bjdata);
15045 oa->write_characters(
15046 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15047 j.m_value.binary->size());
15051 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
15053 oa->write_character(to_char_type(
'U'));
15054 oa->write_character(j.m_value.binary->data()[i]);
15060 oa->write_character(to_char_type(
']'));
15066 case value_t::object:
15068 if (use_bjdata && j.m_value.object->size() == 3 && j.m_value.object->find(
"_ArrayType_") != j.m_value.object->end() && j.m_value.object->find(
"_ArraySize_") != j.m_value.object->end() && j.m_value.object->find(
"_ArrayData_") != j.m_value.object->end())
15070 if (!write_bjdata_ndarray(*j.m_value.object, use_count, use_type))
15078 oa->write_character(to_char_type(
'{'));
15081 bool prefix_required =
true;
15082 if (use_type && !j.m_value.object->empty())
15085 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15086 const bool same_prefix = std::all_of(j.begin(), j.end(),
15087 [
this, first_prefix, use_bjdata](
const BasicJsonType& v)
15089 return ubjson_prefix(v, use_bjdata) == first_prefix;
15092 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z' };
15094 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15096 prefix_required =
false;
15097 oa->write_character(to_char_type(
'$'));
15098 oa->write_character(first_prefix);
15104 oa->write_character(to_char_type(
'#'));
15105 write_number_with_ubjson_prefix(j.m_value.object->size(),
true, use_bjdata);
15108 for (
const auto& el : *j.m_value.object)
15110 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
15111 oa->write_characters(
15112 reinterpret_cast<const CharType*
>(el.first.c_str()),
15114 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
15119 oa->write_character(to_char_type(
'}'));
15125 case value_t::discarded:
15140 static std::size_t calc_bson_entry_header_size(
const string_t& name,
const BasicJsonType& j)
15142 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
15146 static_cast<void>(j);
15149 return 1ul + name.size() + 1u;
15155 void write_bson_entry_header(
const string_t& name,
15156 const std::uint8_t element_type)
15158 oa->write_character(to_char_type(element_type));
15159 oa->write_characters(
15160 reinterpret_cast<const CharType*
>(name.c_str()),
15167 void write_bson_boolean(
const string_t& name,
15170 write_bson_entry_header(name, 0x08);
15171 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
15177 void write_bson_double(
const string_t& name,
15178 const double value)
15180 write_bson_entry_header(name, 0x01);
15181 write_number<double>(value,
true);
15187 static std::size_t calc_bson_string_size(
const string_t& value)
15189 return sizeof(std::int32_t) +
value.size() + 1ul;
15195 void write_bson_string(
const string_t& name,
15196 const string_t& value)
15198 write_bson_entry_header(name, 0x02);
15200 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
15201 oa->write_characters(
15202 reinterpret_cast<const CharType*
>(
value.c_str()),
15209 void write_bson_null(
const string_t& name)
15211 write_bson_entry_header(name, 0x0A);
15217 static std::size_t calc_bson_integer_size(
const std::int64_t value)
15219 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
15220 ?
sizeof(std::int32_t)
15221 :
sizeof(std::int64_t);
15227 void write_bson_integer(
const string_t& name,
15228 const std::int64_t value)
15230 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
15232 write_bson_entry_header(name, 0x10);
15233 write_number<std::int32_t>(
static_cast<std::int32_t
>(value),
true);
15237 write_bson_entry_header(name, 0x12);
15238 write_number<std::int64_t>(
static_cast<std::int64_t
>(value),
true);
15245 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value)
noexcept
15247 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15248 ?
sizeof(std::int32_t)
15249 :
sizeof(std::int64_t);
15255 void write_bson_unsigned(
const string_t& name,
15256 const BasicJsonType& j)
15258 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15260 write_bson_entry_header(name, 0x10 );
15261 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_value.number_unsigned),
true);
15263 else if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15265 write_bson_entry_header(name, 0x12 );
15266 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_value.number_unsigned),
true);
15270 JSON_THROW(out_of_range::create(407,
concat(
"integer number ",
std::to_string(j.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &j));
15277 void write_bson_object_entry(
const string_t& name,
15278 const typename BasicJsonType::object_t& value)
15280 write_bson_entry_header(name, 0x03);
15281 write_bson_object(value);
15287 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
15289 std::size_t array_index = 0ul;
15291 const std::size_t embedded_document_size = std::accumulate(
std::begin(value),
std::end(value),
static_cast<std::size_t
>(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type& el)
15293 return result + calc_bson_element_size(
std::to_string(array_index++), el);
15296 return sizeof(std::int32_t) + embedded_document_size + 1ul;
15302 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t& value)
15304 return sizeof(std::int32_t) +
value.size() + 1ul;
15310 void write_bson_array(
const string_t& name,
15311 const typename BasicJsonType::array_t& value)
15313 write_bson_entry_header(name, 0x04);
15314 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(value)),
true);
15316 std::size_t array_index = 0ul;
15318 for (
const auto& el : value)
15323 oa->write_character(to_char_type(0x00));
15329 void write_bson_binary(
const string_t& name,
15330 const binary_t& value)
15332 write_bson_entry_header(name, 0x05);
15334 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
15335 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
15337 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
15344 static std::size_t calc_bson_element_size(
const string_t& name,
15345 const BasicJsonType& j)
15347 const auto header_size = calc_bson_entry_header_size(name, j);
15350 case value_t::object:
15351 return header_size + calc_bson_object_size(*j.m_value.object);
15353 case value_t::array:
15354 return header_size + calc_bson_array_size(*j.m_value.array);
15356 case value_t::binary:
15357 return header_size + calc_bson_binary_size(*j.m_value.binary);
15359 case value_t::boolean:
15360 return header_size + 1ul;
15362 case value_t::number_float:
15363 return header_size + 8ul;
15365 case value_t::number_integer:
15366 return header_size + calc_bson_integer_size(j.m_value.number_integer);
15368 case value_t::number_unsigned:
15369 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
15371 case value_t::string:
15372 return header_size + calc_bson_string_size(*j.m_value.string);
15374 case value_t::null:
15375 return header_size + 0ul;
15378 case value_t::discarded:
15392 void write_bson_element(
const string_t& name,
15393 const BasicJsonType& j)
15397 case value_t::object:
15398 return write_bson_object_entry(name, *j.m_value.object);
15400 case value_t::array:
15401 return write_bson_array(name, *j.m_value.array);
15403 case value_t::binary:
15404 return write_bson_binary(name, *j.m_value.binary);
15406 case value_t::boolean:
15407 return write_bson_boolean(name, j.m_value.boolean);
15409 case value_t::number_float:
15410 return write_bson_double(name, j.m_value.number_float);
15412 case value_t::number_integer:
15413 return write_bson_integer(name, j.m_value.number_integer);
15415 case value_t::number_unsigned:
15416 return write_bson_unsigned(name, j);
15418 case value_t::string:
15419 return write_bson_string(name, *j.m_value.string);
15421 case value_t::null:
15422 return write_bson_null(name);
15425 case value_t::discarded:
15439 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
15441 std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
15442 [](
size_t result,
const typename BasicJsonType::object_t::value_type& el)
15444 return result += calc_bson_element_size(el.first, el.second);
15447 return sizeof(std::int32_t) + document_size + 1ul;
15454 void write_bson_object(
const typename BasicJsonType::object_t& value)
15456 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(value)),
true);
15458 for (
const auto& el : value)
15460 write_bson_element(el.first, el.second);
15463 oa->write_character(to_char_type(0x00));
15470 static constexpr CharType get_cbor_float_prefix(
float )
15472 return to_char_type(0xFA);
15475 static constexpr CharType get_cbor_float_prefix(
double )
15477 return to_char_type(0xFB);
15484 static constexpr CharType get_msgpack_float_prefix(
float )
15486 return to_char_type(0xCA);
15489 static constexpr CharType get_msgpack_float_prefix(
double )
15491 return to_char_type(0xCB);
15499 template<
typename NumberType,
typename std::enable_if<
15500 std::is_floating_point<NumberType>::value,
int>::type = 0>
15501 void write_number_with_ubjson_prefix(
const NumberType n,
15502 const bool add_prefix,
15503 const bool use_bjdata)
15507 oa->write_character(get_ubjson_float_prefix(n));
15509 write_number(n, use_bjdata);
15513 template<
typename NumberType,
typename std::enable_if<
15514 std::is_unsigned<NumberType>::value,
int>::type = 0>
15515 void write_number_with_ubjson_prefix(
const NumberType n,
15516 const bool add_prefix,
15517 const bool use_bjdata)
15519 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
15523 oa->write_character(to_char_type(
'i'));
15525 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
15527 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
15531 oa->write_character(to_char_type(
'U'));
15533 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
15535 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
15539 oa->write_character(to_char_type(
'I'));
15541 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
15543 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
15547 oa->write_character(to_char_type(
'u'));
15549 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
15551 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15555 oa->write_character(to_char_type(
'l'));
15557 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
15559 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
15563 oa->write_character(to_char_type(
'm'));
15565 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
15567 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15571 oa->write_character(to_char_type(
'L'));
15573 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
15575 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
15579 oa->write_character(to_char_type(
'M'));
15581 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
15587 oa->write_character(to_char_type(
'H'));
15590 const auto number = BasicJsonType(n).dump();
15591 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
15592 for (std::size_t i = 0; i < number.size(); ++i)
15594 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
15600 template <
typename NumberType,
typename std::enable_if <
15601 std::is_signed<NumberType>::value &&
15602 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
15603 void write_number_with_ubjson_prefix(
const NumberType n,
15604 const bool add_prefix,
15605 const bool use_bjdata)
15607 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
15611 oa->write_character(to_char_type(
'i'));
15613 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
15615 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
15619 oa->write_character(to_char_type(
'U'));
15621 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
15623 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
15627 oa->write_character(to_char_type(
'I'));
15629 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
15631 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::max)())))
15635 oa->write_character(to_char_type(
'u'));
15637 write_number(
static_cast<uint16_t
>(n), use_bjdata);
15639 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
15643 oa->write_character(to_char_type(
'l'));
15645 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
15647 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::max)())))
15651 oa->write_character(to_char_type(
'm'));
15653 write_number(
static_cast<uint32_t
>(n), use_bjdata);
15655 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
15659 oa->write_character(to_char_type(
'L'));
15661 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
15668 oa->write_character(to_char_type(
'H'));
15671 const auto number = BasicJsonType(n).dump();
15672 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
15673 for (std::size_t i = 0; i < number.size(); ++i)
15675 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
15684 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
15688 case value_t::null:
15691 case value_t::boolean:
15692 return j.m_value.boolean ?
'T' :
'F';
15694 case value_t::number_integer:
15696 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15700 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15704 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15708 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
15712 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15716 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
15720 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15728 case value_t::number_unsigned:
15730 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
15734 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
15738 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
15742 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
15746 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15750 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
15754 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15758 if (use_bjdata && j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15766 case value_t::number_float:
15767 return get_ubjson_float_prefix(j.m_value.number_float);
15769 case value_t::string:
15772 case value_t::array:
15773 case value_t::binary:
15776 case value_t::object:
15779 case value_t::discarded:
15785 static constexpr CharType get_ubjson_float_prefix(
float )
15790 static constexpr CharType get_ubjson_float_prefix(
double )
15798 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t& value,
const bool use_count,
const bool use_type)
15800 std::map<string_t, CharType> bjdtype = { {
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
15801 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
15804 string_t
key =
"_ArrayType_";
15805 auto it = bjdtype.find(
static_cast<string_t
>(
value.at(key)));
15806 if (it == bjdtype.end())
15810 CharType dtype = it->second;
15812 key =
"_ArraySize_";
15813 std::size_t len = (
value.at(key).empty() ? 0 : 1);
15814 for (
const auto& el :
value.at(key))
15816 len *=
static_cast<std::size_t
>(el.m_value.number_unsigned);
15819 key =
"_ArrayData_";
15820 if (
value.at(key).size() != len)
15825 oa->write_character(
'[');
15826 oa->write_character(
'$');
15827 oa->write_character(dtype);
15828 oa->write_character(
'#');
15830 key =
"_ArraySize_";
15831 write_ubjson(
value.at(key), use_count, use_type,
true,
true);
15833 key =
"_ArrayData_";
15834 if (dtype ==
'U' || dtype ==
'C')
15836 for (
const auto& el :
value.at(key))
15838 write_number(
static_cast<std::uint8_t
>(el.m_value.number_unsigned),
true);
15841 else if (dtype ==
'i')
15843 for (
const auto& el :
value.at(key))
15845 write_number(
static_cast<std::int8_t
>(el.m_value.number_integer),
true);
15848 else if (dtype ==
'u')
15850 for (
const auto& el :
value.at(key))
15852 write_number(
static_cast<std::uint16_t
>(el.m_value.number_unsigned),
true);
15855 else if (dtype ==
'I')
15857 for (
const auto& el :
value.at(key))
15859 write_number(
static_cast<std::int16_t
>(el.m_value.number_integer),
true);
15862 else if (dtype ==
'm')
15864 for (
const auto& el :
value.at(key))
15866 write_number(
static_cast<std::uint32_t
>(el.m_value.number_unsigned),
true);
15869 else if (dtype ==
'l')
15871 for (
const auto& el :
value.at(key))
15873 write_number(
static_cast<std::int32_t
>(el.m_value.number_integer),
true);
15876 else if (dtype ==
'M')
15878 for (
const auto& el :
value.at(key))
15880 write_number(
static_cast<std::uint64_t
>(el.m_value.number_unsigned),
true);
15883 else if (dtype ==
'L')
15885 for (
const auto& el :
value.at(key))
15887 write_number(
static_cast<std::int64_t
>(el.m_value.number_integer),
true);
15890 else if (dtype ==
'd')
15892 for (
const auto& el :
value.at(key))
15894 write_number(
static_cast<float>(el.m_value.number_float),
true);
15897 else if (dtype ==
'D')
15899 for (
const auto& el :
value.at(key))
15901 write_number(
static_cast<double>(el.m_value.number_float),
true);
15924 template<
typename NumberType>
15925 void write_number(
const NumberType n,
const bool OutputIsLittleEndian =
false)
15928 std::array<CharType,
sizeof(NumberType)> vec{};
15929 std::memcpy(vec.data(), &n,
sizeof(NumberType));
15932 if (is_little_endian != OutputIsLittleEndian)
15935 std::reverse(vec.begin(), vec.end());
15938 oa->write_characters(vec.data(),
sizeof(NumberType));
15944#pragma GCC diagnostic push
15945#pragma GCC diagnostic ignored "-Wfloat-equal"
15947 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
15948 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
15949 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
15951 oa->write_character(format == detail::input_format_t::cbor
15952 ? get_cbor_float_prefix(
static_cast<float>(n))
15953 : get_msgpack_float_prefix(
static_cast<float>(n)));
15954 write_number(
static_cast<float>(n));
15958 oa->write_character(format == detail::input_format_t::cbor
15959 ? get_cbor_float_prefix(n)
15960 : get_msgpack_float_prefix(n));
15964#pragma GCC diagnostic pop
15973 template <
typename C = CharType,
15974 enable_if_t < std::is_signed<C>::value&& std::is_signed<char>::value >* =
nullptr >
15977 return *
reinterpret_cast<char*
>(&x);
15980 template <
typename C = CharType,
15984 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
15985 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
15987 std::memcpy(&result, &x,
sizeof(x));
15991 template<
typename C = CharType,
15998 template <
typename InputCharType,
typename C = CharType,
16000 std::is_signed<C>::value&&
16001 std::is_signed<char>::value&&
16002 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
16011 const bool is_little_endian = little_endianness();
16024#include <algorithm>
16034#include <type_traits>
16045#include <type_traits>
16074 namespace dtoa_impl
16077 template<
typename Target,
typename Source>
16080 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
16083 std::memcpy(&target, &source,
sizeof(Source));
16094 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
16105 return { x.f - y.f, x.e };
16114 static_assert(
kPrecision == 64,
"internal error");
16139 const std::uint64_t u_lo = x.
f & 0xFFFFFFFFu;
16140 const std::uint64_t u_hi = x.f >> 32u;
16141 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
16142 const std::uint64_t v_hi = y.f >> 32u;
16144 const std::uint64_t p0 = u_lo * v_lo;
16145 const std::uint64_t p1 = u_lo * v_hi;
16146 const std::uint64_t p2 = u_hi * v_lo;
16147 const std::uint64_t p3 = u_hi * v_hi;
16149 const std::uint64_t p0_hi = p0 >> 32u;
16150 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
16151 const std::uint64_t p1_hi = p1 >> 32u;
16152 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
16153 const std::uint64_t p2_hi = p2 >> 32u;
16155 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
16166 Q += std::uint64_t{ 1 } << (64u - 32u - 1u);
16168 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
16170 return { h, x.e + y.e + 64 };
16181 while ((x.f >> 63u) == 0)
16196 const int delta = x.
e - target_exponent;
16201 return { x.f << delta, target_exponent };
16218 template<
typename FloatType>
16231 static_assert(std::numeric_limits<FloatType>::is_iec559,
16232 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
16234 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
16235 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
16236 constexpr int kMinExp = 1 - kBias;
16237 constexpr std::uint64_t kHiddenBit = std::uint64_t{ 1 } << (kPrecision - 1);
16239 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
16241 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
16242 const std::uint64_t E = bits >> (kPrecision - 1);
16243 const std::uint64_t F = bits & (kHiddenBit - 1);
16245 const bool is_denormal = E == 0;
16246 const diyfp v = is_denormal
16247 ?
diyfp(F, kMinExp)
16248 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
16271 const bool lower_boundary_is_closer = F == 0 && E > 1;
16273 const diyfp m_minus = lower_boundary_is_closer
16274 ?
diyfp(4 * v.
f - 1, v.
e - 2)
16275 :
diyfp(2 * v.
f - 1, v.
e - 1);
16410 constexpr int kCachedPowersMinDecExp = -300;
16411 constexpr int kCachedPowersDecStep = 8;
16413 static constexpr std::array<cached_power, 79> kCachedPowers =
16416 { 0xAB70FE17C79AC6CA, -1060, -300 },
16417 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
16418 { 0xBE5691EF416BD60C, -1007, -284 },
16419 { 0x8DD01FAD907FFC3C, -980, -276 },
16420 { 0xD3515C2831559A83, -954, -268 },
16421 { 0x9D71AC8FADA6C9B5, -927, -260 },
16422 { 0xEA9C227723EE8BCB, -901, -252 },
16423 { 0xAECC49914078536D, -874, -244 },
16424 { 0x823C12795DB6CE57, -847, -236 },
16425 { 0xC21094364DFB5637, -821, -228 },
16426 { 0x9096EA6F3848984F, -794, -220 },
16427 { 0xD77485CB25823AC7, -768, -212 },
16428 { 0xA086CFCD97BF97F4, -741, -204 },
16429 { 0xEF340A98172AACE5, -715, -196 },
16430 { 0xB23867FB2A35B28E, -688, -188 },
16431 { 0x84C8D4DFD2C63F3B, -661, -180 },
16432 { 0xC5DD44271AD3CDBA, -635, -172 },
16433 { 0x936B9FCEBB25C996, -608, -164 },
16434 { 0xDBAC6C247D62A584, -582, -156 },
16435 { 0xA3AB66580D5FDAF6, -555, -148 },
16436 { 0xF3E2F893DEC3F126, -529, -140 },
16437 { 0xB5B5ADA8AAFF80B8, -502, -132 },
16438 { 0x87625F056C7C4A8B, -475, -124 },
16439 { 0xC9BCFF6034C13053, -449, -116 },
16440 { 0x964E858C91BA2655, -422, -108 },
16441 { 0xDFF9772470297EBD, -396, -100 },
16442 { 0xA6DFBD9FB8E5B88F, -369, -92 },
16443 { 0xF8A95FCF88747D94, -343, -84 },
16444 { 0xB94470938FA89BCF, -316, -76 },
16445 { 0x8A08F0F8BF0F156B, -289, -68 },
16446 { 0xCDB02555653131B6, -263, -60 },
16447 { 0x993FE2C6D07B7FAC, -236, -52 },
16448 { 0xE45C10C42A2B3B06, -210, -44 },
16449 { 0xAA242499697392D3, -183, -36 },
16450 { 0xFD87B5F28300CA0E, -157, -28 },
16451 { 0xBCE5086492111AEB, -130, -20 },
16452 { 0x8CBCCC096F5088CC, -103, -12 },
16453 { 0xD1B71758E219652C, -77, -4 },
16454 { 0x9C40000000000000, -50, 4 },
16455 { 0xE8D4A51000000000, -24, 12 },
16456 { 0xAD78EBC5AC620000, 3, 20 },
16457 { 0x813F3978F8940984, 30, 28 },
16458 { 0xC097CE7BC90715B3, 56, 36 },
16459 { 0x8F7E32CE7BEA5C70, 83, 44 },
16460 { 0xD5D238A4ABE98068, 109, 52 },
16461 { 0x9F4F2726179A2245, 136, 60 },
16462 { 0xED63A231D4C4FB27, 162, 68 },
16463 { 0xB0DE65388CC8ADA8, 189, 76 },
16464 { 0x83C7088E1AAB65DB, 216, 84 },
16465 { 0xC45D1DF942711D9A, 242, 92 },
16466 { 0x924D692CA61BE758, 269, 100 },
16467 { 0xDA01EE641A708DEA, 295, 108 },
16468 { 0xA26DA3999AEF774A, 322, 116 },
16469 { 0xF209787BB47D6B85, 348, 124 },
16470 { 0xB454E4A179DD1877, 375, 132 },
16471 { 0x865B86925B9BC5C2, 402, 140 },
16472 { 0xC83553C5C8965D3D, 428, 148 },
16473 { 0x952AB45CFA97A0B3, 455, 156 },
16474 { 0xDE469FBD99A05FE3, 481, 164 },
16475 { 0xA59BC234DB398C25, 508, 172 },
16476 { 0xF6C69A72A3989F5C, 534, 180 },
16477 { 0xB7DCBF5354E9BECE, 561, 188 },
16478 { 0x88FCF317F22241E2, 588, 196 },
16479 { 0xCC20CE9BD35C78A5, 614, 204 },
16480 { 0x98165AF37B2153DF, 641, 212 },
16481 { 0xE2A0B5DC971F303A, 667, 220 },
16482 { 0xA8D9D1535CE3B396, 694, 228 },
16483 { 0xFB9B7CD9A4A7443C, 720, 236 },
16484 { 0xBB764C4CA7A44410, 747, 244 },
16485 { 0x8BAB8EEFB6409C1A, 774, 252 },
16486 { 0xD01FEF10A657842C, 800, 260 },
16487 { 0x9B10A4E5E9913129, 827, 268 },
16488 { 0xE7109BFBA19C0C9D, 853, 276 },
16489 { 0xAC2820D9623BF429, 880, 284 },
16490 { 0x80444B5E7AA7CF85, 907, 292 },
16491 { 0xBF21E44003ACDD2D, 933, 300 },
16492 { 0x8E679C2F5E44FF8F, 960, 308 },
16493 { 0xD433179D9C8CB841, 986, 316 },
16494 { 0x9E19DB92B4E31BA9, 1013, 324 },
16504 const int f =
kAlpha - e - 1;
16505 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
16507 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
16509 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
16511 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
16525 if (n >= 1000000000)
16527 pow10 = 1000000000;
16531 if (n >= 100000000)
16576 inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
16577 std::uint64_t rest, std::uint64_t ten_k)
16604 && delta - rest >= ten_k
16605 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
16620 static_assert(
kAlpha >= -60,
"internal error");
16621 static_assert(
kGamma <= -32,
"internal error");
16638 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).
f;
16648 const diyfp one(std::uint64_t{ 1 } << -M_plus.
e, M_plus.
e);
16650 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
16651 std::uint64_t p2 = M_plus.
f & (one.f - 1);
16659 std::uint32_t pow10{};
16687 const std::uint32_t d = p1 / pow10;
16688 const std::uint32_t r = p1 % pow10;
16694 buffer[length++] =
static_cast<char>(
'0' + d);
16713 const std::uint64_t rest = (std::uint64_t{ p1 } << -one.e) + p2;
16718 decimal_exponent += n;
16729 const std::uint64_t ten_n = std::uint64_t{ pow10 } << -one.e;
16730 grisu2_round(buffer, length, dist, delta, rest, ten_n);
16791 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
16793 const std::uint64_t d = p2 >> -one.e;
16794 const std::uint64_t r = p2 & (one.f - 1);
16801 buffer[length++] =
static_cast<char>(
'0' + d);
16826 decimal_exponent -= m;
16834 const std::uint64_t ten_m = one.f;
16858 inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
16875 const diyfp c_minus_k(cached.
f, cached.
e);
16903 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
16904 const diyfp M_plus(w_plus.
f - 1, w_plus.
e);
16906 decimal_exponent = -cached.
k;
16916 template<
typename FloatType>
16918 void
grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType value)
16921 "internal error: not enough precision");
16973 auto k =
static_cast<std::uint32_t
>(e);
16979 *buf++ =
static_cast<char>(
'0' + k);
16983 *buf++ =
static_cast<char>(
'0' + k / 10);
16985 *buf++ =
static_cast<char>(
'0' + k);
16989 *buf++ =
static_cast<char>(
'0' + k / 100);
16991 *buf++ =
static_cast<char>(
'0' + k / 10);
16993 *buf++ =
static_cast<char>(
'0' + k);
17011 int min_exp,
int max_exp)
17017 const int n = len + decimal_exponent;
17023 if (k <= n && n <= max_exp)
17028 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
17032 return buf + (
static_cast<size_t>(n) + 2);
17035 if (0 < n && n <= max_exp)
17042 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
17044 return buf + (
static_cast<size_t>(k) + 1U);
17047 if (min_exp < n && n <= 0)
17052 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
17055 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
17056 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
17071 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
17073 buf += 1 +
static_cast<size_t>(k);
17092 template<
typename FloatType>
17095 char*
to_chars(
char* first, const
char* last, FloatType value)
17097 static_cast<void>(last);
17101 if (std::signbit(
value))
17108#pragma GCC diagnostic push
17109#pragma GCC diagnostic ignored "-Wfloat-equal"
17120#pragma GCC diagnostic pop
17123 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
17130 int decimal_exponent = 0;
17133 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
17136 constexpr int kMinExp = -4;
17138 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
17141 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
17142 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
17181 template<
typename BasicJsonType>
17184 using string_t =
typename BasicJsonType::string_t;
17185 using number_float_t =
typename BasicJsonType::number_float_t;
17186 using number_integer_t =
typename BasicJsonType::number_integer_t;
17187 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
17188 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
17189 static constexpr std::uint8_t UTF8_ACCEPT = 0;
17190 static constexpr std::uint8_t UTF8_REJECT = 1;
17201 ,
loc(
std::localeconv())
17239 const bool pretty_print,
17241 const unsigned int indent_step,
17242 const unsigned int current_indent = 0)
17244 switch (val.m_type)
17248 if (val.m_value.object->empty())
17250 o->write_characters(
"{}", 2);
17256 o->write_characters(
"{\n", 2);
17259 const auto new_indent = current_indent + indent_step;
17266 auto i = val.m_value.object->cbegin();
17267 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
17270 o->write_character(
'\"');
17272 o->write_characters(
"\": ", 3);
17274 o->write_characters(
",\n", 2);
17279 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
17281 o->write_character(
'\"');
17283 o->write_characters(
"\": ", 3);
17286 o->write_character(
'\n');
17287 o->write_characters(
indent_string.c_str(), current_indent);
17288 o->write_character(
'}');
17292 o->write_character(
'{');
17295 auto i = val.m_value.object->cbegin();
17296 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
17298 o->write_character(
'\"');
17300 o->write_characters(
"\":", 2);
17302 o->write_character(
',');
17307 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
17308 o->write_character(
'\"');
17310 o->write_characters(
"\":", 2);
17313 o->write_character(
'}');
17321 if (val.m_value.array->empty())
17323 o->write_characters(
"[]", 2);
17329 o->write_characters(
"[\n", 2);
17332 const auto new_indent = current_indent + indent_step;
17339 for (
auto i = val.m_value.array->cbegin();
17340 i != val.m_value.array->cend() - 1; ++i)
17344 o->write_characters(
",\n", 2);
17350 dump(val.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
17352 o->write_character(
'\n');
17353 o->write_characters(
indent_string.c_str(), current_indent);
17354 o->write_character(
']');
17358 o->write_character(
'[');
17361 for (
auto i = val.m_value.array->cbegin();
17362 i != val.m_value.array->cend() - 1; ++i)
17365 o->write_character(
',');
17370 dump(val.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
17372 o->write_character(
']');
17380 o->write_character(
'\"');
17382 o->write_character(
'\"');
17390 o->write_characters(
"{\n", 2);
17393 const auto new_indent = current_indent + indent_step;
17401 o->write_characters(
"\"bytes\": [", 10);
17403 if (!val.m_value.binary->empty())
17405 for (
auto i = val.m_value.binary->cbegin();
17406 i != val.m_value.binary->cend() - 1; ++i)
17409 o->write_characters(
", ", 2);
17411 dump_integer(val.m_value.binary->back());
17414 o->write_characters(
"],\n", 3);
17417 o->write_characters(
"\"subtype\": ", 11);
17418 if (val.m_value.binary->has_subtype())
17420 dump_integer(val.m_value.binary->subtype());
17424 o->write_characters(
"null", 4);
17426 o->write_character(
'\n');
17427 o->write_characters(
indent_string.c_str(), current_indent);
17428 o->write_character(
'}');
17432 o->write_characters(
"{\"bytes\":[", 10);
17434 if (!val.m_value.binary->empty())
17436 for (
auto i = val.m_value.binary->cbegin();
17437 i != val.m_value.binary->cend() - 1; ++i)
17440 o->write_character(
',');
17442 dump_integer(val.m_value.binary->back());
17445 o->write_characters(
"],\"subtype\":", 12);
17446 if (val.m_value.binary->has_subtype())
17448 dump_integer(val.m_value.binary->subtype());
17449 o->write_character(
'}');
17453 o->write_characters(
"null}", 5);
17461 if (val.m_value.boolean)
17463 o->write_characters(
"true", 4);
17467 o->write_characters(
"false", 5);
17474 dump_integer(val.m_value.number_integer);
17480 dump_integer(val.m_value.number_unsigned);
17486 dump_float(val.m_value.number_float);
17492 o->write_characters(
"<discarded>", 11);
17498 o->write_characters(
"null", 4);
17524 std::uint32_t codepoint{};
17532 for (std::size_t i = 0; i < s.size(); ++i)
17534 const auto byte =
static_cast<std::uint8_t
>(s[i]);
17536 switch (decode(
state, codepoint,
byte))
17595 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
17597 if (codepoint <= 0xFFFF)
17601 static_cast<std::uint16_t
>(codepoint)));
17607 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
17608 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
17609 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
17697 state = UTF8_ACCEPT;
17753 o->write_characters(
"\\ufffd", 6);
17757 o->write_characters(
"\xEF\xBF\xBD", 3);
17777 inline unsigned int count_digits(number_unsigned_t x)
noexcept
17779 unsigned int n_digits = 1;
17788 return n_digits + 1;
17792 return n_digits + 2;
17796 return n_digits + 3;
17808 static std::string hex_bytes(std::uint8_t
byte)
17810 std::string result =
"FF";
17811 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
17812 result[0] = nibble_to_hex[
byte / 16];
17813 result[1] = nibble_to_hex[
byte % 16];
17818 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
17819 bool is_negative_number(NumberType x)
17824 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
17825 bool is_negative_number(NumberType )
17840 std::is_integral<NumberType>::value ||
17841 std::is_same<NumberType, number_unsigned_t>::value ||
17842 std::is_same<NumberType, number_integer_t>::value ||
17843 std::is_same<NumberType, binary_char_t>::value,
17845 void dump_integer(NumberType x)
17847 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
17850 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
17851 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
17852 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
17853 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
17854 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
17855 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
17856 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
17857 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
17858 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
17859 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
17866 o->write_character(
'0');
17873 number_unsigned_t abs_value;
17875 unsigned int n_chars{};
17877 if (is_negative_number(x))
17880 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
17883 n_chars = 1 + count_digits(abs_value);
17887 abs_value =
static_cast<number_unsigned_t
>(x);
17888 n_chars = count_digits(abs_value);
17896 buffer_ptr += n_chars;
17900 while (abs_value >= 100)
17902 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
17904 *(--buffer_ptr) = digits_to_99[digits_index][1];
17905 *(--buffer_ptr) = digits_to_99[digits_index][0];
17908 if (abs_value >= 10)
17910 const auto digits_index =
static_cast<unsigned>(abs_value);
17911 *(--buffer_ptr) = digits_to_99[digits_index][1];
17912 *(--buffer_ptr) = digits_to_99[digits_index][0];
17916 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
17930 void dump_float(number_float_t x)
17933 if (!std::isfinite(x))
17935 o->write_characters(
"null", 4);
17944 static constexpr bool is_ieee_single_or_double
17945 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
17946 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
17948 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
17951 void dump_float(number_float_t x, std::true_type )
17956 o->write_characters(
begin,
static_cast<size_t>(
end -
begin));
17959 void dump_float(number_float_t x, std::false_type )
17962 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
17994 o->write_characters(
number_buffer.data(),
static_cast<std::size_t
>(len));
17997 const bool value_is_int_like =
18001 return c ==
'.' || c ==
'e';
18004 if (value_is_int_like)
18006 o->write_characters(
".0", 2);
18031 static std::uint8_t decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
18033 static const std::array<std::uint8_t, 400> utf8d =
18036 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18037 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18038 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18039 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18040 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
18041 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18042 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
18043 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
18044 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
18045 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
18046 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
18047 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
18048 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
18049 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
18054 const std::uint8_t type = utf8d[byte];
18056 codep = (
state != UTF8_ACCEPT)
18057 ? (
byte & 0x3fu) | (codep << 6u)
18058 : (0xFFu >> type) & (byte);
18060 std::size_t index = 256u +
static_cast<size_t>(
state) * 16u +
static_cast<size_t>(type);
18062 state = utf8d[index];
18071 number_unsigned_t remove_sign(number_unsigned_t x)
18086 inline number_unsigned_t remove_sign(number_integer_t x)
noexcept
18088 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
18089 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
18094 output_adapter_t<char> o =
nullptr;
18127#include <functional>
18128#include <initializer_list>
18131#include <stdexcept>
18132#include <type_traits>
18144 template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
18145 class Allocator = std::allocator<std::pair<const Key, T>>>
18150 using Container = std::vector<std::pair<const Key, T>, Allocator>;
18155#ifdef JSON_HAS_CPP_14
18165 template <
class It>
18173 for (
auto it = this->
begin(); it != this->
end(); ++it)
18175 if (m_compare(it->first, key))
18177 return { it,
false };
18180 Container::emplace_back(key, t);
18181 return { --this->
end(),
true };
18186 return emplace(key, T{}).first->second;
18196 for (
auto it = this->
begin(); it != this->
end(); ++it)
18198 if (m_compare(it->first, key))
18204 JSON_THROW(std::out_of_range(
"key not found"));
18207 const T&
at(
const Key& key)
const
18209 for (
auto it = this->
begin(); it != this->
end(); ++it)
18211 if (m_compare(it->first, key))
18217 JSON_THROW(std::out_of_range(
"key not found"));
18222 for (
auto it = this->
begin(); it != this->
end(); ++it)
18224 if (m_compare(it->first, key))
18227 for (
auto next = it; ++next != this->
end(); ++it)
18232 Container::pop_back();
18241 return erase(pos, std::next(pos));
18246 const auto elements_affected = std::distance(first, last);
18269 for (
auto it = first; std::next(it, elements_affected) !=
Container::end(); ++it)
18272 new (&*it)
value_type{ std::move(*std::next(it, elements_affected)) };
18280 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
18294 for (
auto it = this->
begin(); it != this->
end(); ++it)
18296 if (m_compare(it->first, key))
18306 for (
auto it = this->
begin(); it != this->
end(); ++it)
18308 if (m_compare(it->first, key))
18318 for (
auto it = this->
begin(); it != this->
end(); ++it)
18320 if (m_compare(it->first, key))
18330 return emplace(value.first, std::move(value.second));
18335 for (
auto it = this->
begin(); it != this->
end(); ++it)
18337 if (m_compare(it->first, value.first))
18339 return { it,
false };
18342 Container::push_back(value);
18343 return { --this->
end(),
true };
18346 template<
typename InputIt>
18347 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
18348 std::input_iterator_tag>::value>::type;
18350 template<
typename InputIt,
typename = require_input_iter<InputIt>>
18353 for (
auto it = first; it != last; ++it)
18366#if defined(JSON_HAS_CPP_17)
18368#include <string_view>
18404 friend class ::nlohmann::json_pointer;
18408 template<
typename BasicJsonType,
typename InputType>
18409 friend class ::nlohmann::detail::parser;
18410 friend ::nlohmann::detail::serializer<basic_json>;
18411 template<
typename BasicJsonType>
18412 friend class ::nlohmann::detail::iter_impl;
18413 template<
typename BasicJsonType,
typename CharType>
18414 friend class ::nlohmann::detail::binary_writer;
18415 template<
typename BasicJsonType,
typename InputType,
typename SAX>
18416 friend class ::nlohmann::detail::binary_reader;
18417 template<
typename BasicJsonType>
18418 friend class ::nlohmann::detail::json_sax_dom_parser;
18419 template<
typename BasicJsonType>
18420 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
18421 friend class ::nlohmann::detail::exception;
18430 template<
typename InputAdapterType>
18431 static ::nlohmann::detail::parser<basic_json, InputAdapterType> parser(
18432 InputAdapterType adapter,
18434 const bool allow_exceptions =
true,
18435 const bool ignore_comments =
false
18438 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
18439 std::move(cb), allow_exceptions, ignore_comments);
18444 template<
typename BasicJsonType>
18446 template<
typename BasicJsonType>
18448 template<
typename Iterator>
18452 template<
typename CharType>
18455 template<
typename InputType>
18466 template<
typename T,
typename SFINAE>
18523 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
18525 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
18553 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
18554 result[
"name"] =
"JSON for Modern C++";
18555 result[
"url"] =
"https://github.com/nlohmann/json";
18556 result[
"version"][
"string"] =
18565 result[
"platform"] =
"win32";
18566#elif defined __linux__
18567 result[
"platform"] =
"linux";
18568#elif defined __APPLE__
18569 result[
"platform"] =
"apple";
18570#elif defined __unix__
18571 result[
"platform"] =
"unix";
18573 result[
"platform"] =
"unknown";
18576#if defined(__ICC) || defined(__INTEL_COMPILER)
18577 result[
"compiler"] = { {
"family",
"icc"}, {
"version", __INTEL_COMPILER} };
18578#elif defined(__clang__)
18579 result[
"compiler"] = { {
"family",
"clang"}, {
"version", __clang_version__} };
18580#elif defined(__GNUC__) || defined(__GNUG__)
18581 result[
"compiler"] = { {
"family",
"gcc"}, {
"version",
detail::concat(
18587#elif defined(__HP_cc) || defined(__HP_aCC)
18588 result[
"compiler"] =
"hp"
18589#elif defined(__IBMCPP__)
18590 result[
"compiler"] = { {
"family",
"ilecpp"}, {
"version", __IBMCPP__} };
18591#elif defined(_MSC_VER)
18592 result[
"compiler"] = { {
"family",
"msvc"}, {
"version", _MSC_VER} };
18593#elif defined(__PGI)
18594 result[
"compiler"] = { {
"family",
"pgcpp"}, {
"version", __PGI} };
18595#elif defined(__SUNPRO_CC)
18596 result[
"compiler"] = { {
"family",
"sunpro"}, {
"version", __SUNPRO_CC} };
18598 result[
"compiler"] = { {
"family",
"unknown"}, {
"version",
"unknown"} };
18602#if defined(_MSVC_LANG)
18604#elif defined(__cplusplus)
18607 result[
"compiler"][
"c++"] =
"unknown";
18626#if defined(JSON_HAS_CPP_14)
18639 AllocatorType<std::pair<
const StringType,
18644 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
18679 template<
typename T,
typename... Args>
18681 static T* create(Args&& ... args)
18683 AllocatorType<T> alloc;
18684 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
18686 auto deleter = [&](T* obj)
18688 AllocatorTraits::deallocate(alloc, obj, 1);
18690 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
18691 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
18693 return obj.release();
18746 json_value() =
default;
18748 json_value(
boolean_t v) noexcept : boolean(v) {}
18762 object = create<object_t>();
18768 array = create<array_t>();
18774 string = create<string_t>(
"");
18780 binary = create<binary_t>();
18786 boolean =
static_cast<boolean_t>(
false);
18862 std::vector<basic_json> stack;
18867 stack.reserve(
array->size());
18868 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
18872 stack.reserve(
object->size());
18873 for (
auto&& it : *
object)
18875 stack.push_back(std::move(it.second));
18879 while (!stack.empty())
18882 basic_json current_item(std::move(stack.back()));
18887 if (current_item.is_array())
18889 std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), std::back_inserter(stack));
18891 current_item.m_value.array->clear();
18893 else if (current_item.is_object())
18895 for (
auto&& it : *current_item.m_value.object)
18897 stack.push_back(std::move(it.second));
18900 current_item.m_value.object->clear();
18912 AllocatorType<object_t> alloc;
18913 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
18914 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
18920 AllocatorType<array_t> alloc;
18921 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
18922 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
18928 AllocatorType<string_t> alloc;
18929 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
18930 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
18936 AllocatorType<binary_t> alloc;
18937 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
18938 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
18975 void assert_invariant(
bool check_parents =
true) const noexcept
18982#if JSON_DIAGNOSTICS
18988 return j.m_parent ==
this;
18993 static_cast<void>(check_parents);
18998#if JSON_DIAGNOSTICS
19003 for (
auto& element : *
m_value.array)
19005 element.m_parent =
this;
19012 for (
auto& element : *
m_value.object)
19014 element.second.m_parent =
this;
19035#if JSON_DIAGNOSTICS
19038 (it + i)->m_parent =
this;
19041 static_cast<void>(count_set_parents);
19046 reference set_parent(
reference j, std::size_t old_capacity =
static_cast<std::size_t
>(-1))
19048#if JSON_DIAGNOSTICS
19049 if (old_capacity !=
static_cast<std::size_t
>(-1))
19063#ifdef JSON_HEDLEY_MSVC_VERSION
19064#pragma warning(push )
19065#pragma warning(disable : 4127)
19072#ifdef JSON_HEDLEY_MSVC_VERSION
19073#pragma warning( pop )
19078 static_cast<void>(j);
19079 static_cast<void>(old_capacity);
19111 assert_invariant();
19119 assert_invariant();
19124 template <
typename CompatibleType,
19130 std::forward<CompatibleType>(val))))
19134 assert_invariant();
19139 template <
typename BasicJsonType,
19144 using other_boolean_t =
typename BasicJsonType::boolean_t;
19145 using other_number_float_t =
typename BasicJsonType::number_float_t;
19146 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
19147 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
19148 using other_string_t =
typename BasicJsonType::string_t;
19149 using other_object_t =
typename BasicJsonType::object_t;
19150 using other_array_t =
typename BasicJsonType::array_t;
19151 using other_binary_t =
typename BasicJsonType::binary_t;
19153 switch (val.type())
19189 assert_invariant();
19195 bool type_deduction =
true,
19200 bool is_an_object = std::all_of(
init.begin(),
init.end(),
19203 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
19207 if (!type_deduction)
19212 is_an_object =
false;
19228 for (
auto& element_ref :
init)
19232 std::move(*((*element.m_value.array)[0].m_value.string)),
19233 std::move((*element.m_value.array)[1]));
19244 assert_invariant();
19254 res.m_value =
init;
19276 res.m_value = std::move(
init);
19312 m_value.array = create<array_t>(cnt, val);
19314 assert_invariant();
19319 template <
class InputIT,
typename std::enable_if <
19320 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
19321 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
19334 m_type = first.m_object->m_type;
19346 || !last.m_it.primitive_iterator.is_end()))
19366 m_value.number_integer = first.m_object->m_value.number_integer;
19372 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
19378 m_value.number_float = first.m_object->m_value.number_float;
19384 m_value.boolean = first.m_object->m_value.boolean;
19390 m_value = *first.m_object->m_value.string;
19396 m_value.object = create<object_t>(first.m_it.object_iterator,
19397 last.m_it.object_iterator);
19403 m_value.array = create<array_t>(first.m_it.array_iterator,
19404 last.m_it.array_iterator);
19410 m_value = *first.m_object->m_value.binary;
19421 assert_invariant();
19429 template<
typename JsonRef,
19431 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
19437 : m_type(other.m_type)
19440 other.assert_invariant();
19499 assert_invariant();
19505 : m_type(std::move(other.m_type)),
19506 m_value(std::move(other.m_value))
19509 other.assert_invariant(
false);
19513 other.m_value = {};
19516 assert_invariant();
19522 std::is_nothrow_move_constructible<value_t>::value&&
19523 std::is_nothrow_move_assignable<value_t>::value&&
19524 std::is_nothrow_move_constructible<json_value>::value&&
19525 std::is_nothrow_move_assignable<json_value>::value
19529 other.assert_invariant();
19532 swap(m_type, other.m_type);
19536 assert_invariant();
19544 assert_invariant(
false);
19562 const char indent_char =
' ',
19563 const bool ensure_ascii =
false,
19571 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
19575 s.dump(*
this,
false, ensure_ascii, 0);
19723 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
19811 template<
typename ReferenceType,
typename ThisType>
19812 static ReferenceType get_ref_impl(ThisType& obj)
19815 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
19832 template<
typename PointerType,
typename std::enable_if<
19833 std::is_pointer<PointerType>::value,
int>
::type = 0>
19834 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
19837 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
19842 template <
typename PointerType,
typename std::enable_if <
19843 std::is_pointer<PointerType>::value&&
19844 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >
::type = 0 >
19845 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
19848 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
19890 template <
typename ValueType,
19898 auto ret = ValueType();
19933 template <
typename ValueType,
19935 detail::has_non_default_from_json<basic_json_t, ValueType>::value,
19937 ValueType get_impl(detail::priority_tag<1> )
const noexcept(
noexcept(
19958 template <
typename BasicJsonType,
19960 detail::is_basic_json<BasicJsonType>::value,
19962 BasicJsonType get_impl(detail::priority_tag<2> )
const
19981 template<
typename BasicJsonType,
19983 std::is_same<BasicJsonType, basic_json_t>::value,
19985 basic_json get_impl(detail::priority_tag<3> )
const
19994 template<
typename PointerType,
19996 std::is_pointer<PointerType>::value,
19998 constexpr auto get_impl(detail::priority_tag<4> )
const noexcept
19999 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
20002 return get_ptr<PointerType>();
20029 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
20030#if defined(JSON_HAS_CPP_14)
20034 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {})))
20040 static_assert(!std::is_reference<ValueTypeCV>::value,
20041 "get() cannot be used with reference types, you might want to use get_ref()");
20042 return get_impl<ValueType>(detail::priority_tag<4> {});
20072 template<
typename PointerType,
typename std::enable_if<
20073 std::is_pointer<PointerType>::value,
int>
::type = 0>
20074 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template
get_ptr<PointerType>())
20077 return get_ptr<PointerType>();
20082 template <
typename ValueType,
20087 ValueType&
get_to(ValueType& v)
const noexcept(
noexcept(
20096 template<
typename ValueType,
20107 typename T, std::size_t N,
20108 typename Array = T(&)[N],
20113 std::declval<const basic_json_t&>(), v)))
20121 template<
typename ReferenceType,
typename std::enable_if<
20122 std::is_reference<ReferenceType>::value,
int>
::type = 0>
20126 return get_ref_impl<ReferenceType>(*
this);
20131 template <
typename ReferenceType,
typename std::enable_if <
20132 std::is_reference<ReferenceType>::value&&
20133 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >
::type = 0 >
20137 return get_ref_impl<ReferenceType>(*
this);
20169 template <
typename ValueType,
typename std::enable_if <
20177#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
20180#if defined(JSON_HAS_CPP_17)
20188 return get<ValueType>();
20200 return *get_ptr<binary_t*>();
20212 return *get_ptr<const binary_t*>();
20235 return set_parent(
m_value.array->at(idx));
20258 return m_value.array->at(idx);
20282 auto it =
m_value.object->find(key);
20283 if (it ==
m_value.object->end())
20287 return set_parent(it->second);
20302 auto it =
m_value.object->find(std::forward<KeyType>(key));
20303 if (it ==
m_value.object->end())
20307 return set_parent(it->second);
20320 auto it =
m_value.object->find(key);
20321 if (it ==
m_value.object->end())
20340 auto it =
m_value.object->find(std::forward<KeyType>(key));
20341 if (it ==
m_value.object->end())
20356 m_value.array = create<array_t>();
20357 assert_invariant();
20364 if (idx >=
m_value.array->size())
20366#if JSON_DIAGNOSTICS
20368 const auto old_size =
m_value.array->size();
20369 const auto old_capacity =
m_value.array->capacity();
20371 m_value.array->resize(idx + 1);
20373#if JSON_DIAGNOSTICS
20385 assert_invariant();
20388 return m_value.array->operator[](idx);
20401 return m_value.array->operator[](idx);
20415 m_value.object = create<object_t>();
20416 assert_invariant();
20422 auto result =
m_value.object->emplace(std::move(key),
nullptr);
20423 return set_parent(result.first->second);
20436 auto it =
m_value.object->find(key);
20446 template<
typename T>
20449 return operator[](
typename object_t::key_type(key));
20452 template<
typename T>
20455 return operator[](
typename object_t::key_type(key));
20468 m_value.object = create<object_t>();
20469 assert_invariant();
20475 auto result =
m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
20476 return set_parent(result.first->second);
20491 auto it =
m_value.object->find(std::forward<KeyType>(key));
20503 std::is_same<KeyType, typename object_t::key_type>::value
20505 && !std::is_same<value_t, ValueType>::value,
int > = 0 >
20506 typename std::decay<ValueType>::type
value(
const KeyType& key, ValueType&& default_value)
const
20512 const auto it =
find(key);
20515 return it->template get<typename std::decay<ValueType>::type>();
20518 return std::forward<ValueType>(default_value);
20527 string_t value(
const typename object_t::key_type& key,
const char* default_value)
const
20537 && !std::is_same<value_t, ValueType>::value,
int > = 0 >
20538 typename std::decay<ValueType>::type
value(
const char* key, ValueType&& default_value)
const
20540 return value(
typename object_t::key_type(key), std::forward<ValueType>(default_value));
20545 return value(
typename object_t::key_type(key),
string_t(default_value));
20553 && !std::is_same<value_t, ValueType>::value
20555 typename std::decay<ValueType>::type
value(KeyType&& key, ValueType&& default_value)
const
20561 const auto it =
find(std::forward<KeyType>(key));
20564 return it->template get<typename std::decay<ValueType>::type>();
20567 return std::forward<ValueType>(default_value);
20580 return value(std::forward<KeyType>(key),
string_t(default_value));
20595 return ptr.get_checked(
this).template get<ValueType>();
20599 return default_value;
20609 ValueType
value(const ::nlohmann::json_pointer<BasicJsonType>& ptr,
const ValueType& default_value)
const
20611 return value(ptr.convert(), default_value);
20623 template<
typename BasicJsonType>
20628 return value(ptr.convert(), default_value);
20666 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
20667 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
20676 IteratorType result =
end();
20694 AllocatorType<string_t> alloc;
20695 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.string);
20696 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
20701 AllocatorType<binary_t> alloc;
20702 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.binary);
20703 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
20708 assert_invariant();
20714 result.m_it.object_iterator =
m_value.object->erase(pos.m_it.object_iterator);
20720 result.m_it.array_iterator =
m_value.array->erase(pos.m_it.array_iterator);
20736 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
20737 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
20738 IteratorType
erase(IteratorType first, IteratorType last)
20746 IteratorType result =
end();
20758 || !last.m_it.primitive_iterator.is_end()))
20765 AllocatorType<string_t> alloc;
20766 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.string);
20767 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
20772 AllocatorType<binary_t> alloc;
20773 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.binary);
20774 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
20779 assert_invariant();
20785 result.m_it.object_iterator =
m_value.object->erase(first.m_it.object_iterator,
20786 last.m_it.object_iterator);
20792 result.m_it.array_iterator =
m_value.array->erase(first.m_it.array_iterator,
20793 last.m_it.array_iterator);
20809 size_type erase_internal(KeyType&& key)
20817 return m_value.object->erase(std::forward<KeyType>(key));
20821 !detail::has_erase_with_key_type<basic_json_t, KeyType>::value,
int > = 0 >
20822 size_type erase_internal(KeyType&& key)
20830 const auto it =
m_value.object->find(std::forward<KeyType>(key));
20831 if (it !=
m_value.object->end())
20847 return erase_internal(key);
20856 return erase_internal(std::forward<KeyType>(key));
20893 auto result =
end();
20897 result.m_it.object_iterator =
m_value.object->find(key);
20907 auto result = cend();
20911 result.m_it.object_iterator =
m_value.object->find(key);
20923 auto result =
end();
20927 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyType>(key));
20939 auto result = cend();
20943 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyType>(key));
20964 return is_object() ?
m_value.object->count(std::forward<KeyType>(key)) : 0;
20969 bool contains(
const typename object_t::key_type& key)
const
20987 return ptr.contains(
this);
20990 template<
typename BasicJsonType>
20992 bool contains(
const typename ::nlohmann::json_pointer<BasicJsonType> ptr)
const
20994 return ptr.contains(
this);
21012 result.set_begin();
21028 result.set_begin();
21108 return ref.items();
21119 return ref.items();
21124 iteration_proxy<iterator> items() noexcept
21126 return iteration_proxy<iterator>(*
this);
21131 iteration_proxy<const_iterator> items() const noexcept
21133 return iteration_proxy<const_iterator>(*
this);
21148 bool empty() const noexcept
21161 return m_value.array->empty();
21167 return m_value.object->empty();
21200 return m_value.array->size();
21206 return m_value.object->size();
21233 return m_value.array->max_size();
21239 return m_value.object->max_size();
21270 void clear() noexcept
21344 assert_invariant();
21348 const auto old_capacity =
m_value.array->capacity();
21349 m_value.array->push_back(std::move(val));
21350 set_parent(
m_value.array->back(), old_capacity);
21377 assert_invariant();
21381 const auto old_capacity =
m_value.array->capacity();
21382 m_value.array->push_back(val);
21383 set_parent(
m_value.array->back(), old_capacity);
21409 assert_invariant();
21413 auto res =
m_value.object->insert(val);
21414 set_parent(res.first->second);
21432 push_back(
typename object_t::value_type(
21433 std::move(key.get_ref<
string_t&>()), (
init.begin() + 1)->moved_or_copied()));
21451 template<
class... Args>
21465 assert_invariant();
21469 const auto old_capacity =
m_value.array->capacity();
21470 m_value.array->emplace_back(std::forward<Args>(args)...);
21471 return set_parent(
m_value.array->back(), old_capacity);
21476 template<
class... Args>
21490 assert_invariant();
21494 auto res =
m_value.object->emplace(std::forward<Args>(args)...);
21495 set_parent(res.first->second);
21499 it.m_it.object_iterator = res.first;
21502 return { it, res.second };
21508 template<
typename... Args>
21550 return insert(pos, val);
21653 update(j.begin(), j.end(), merge_objects);
21664 m_value.object = create<object_t>();
21665 assert_invariant();
21685 for (
auto it = first; it != last; ++it)
21687 if (merge_objects && it.value().is_object())
21689 auto it2 =
m_value.object->find(it.key());
21690 if (it2 !=
m_value.object->end())
21692 it2->second.update(it.value(),
true);
21696 m_value.object->operator[](it.key()) = it.value();
21697#if JSON_DIAGNOSTICS
21698 m_value.object->operator[](it.key()).m_parent =
this;
21706 std::is_nothrow_move_constructible<value_t>::value&&
21707 std::is_nothrow_move_assignable<value_t>::value&&
21708 std::is_nothrow_move_constructible<json_value>::value&&
21709 std::is_nothrow_move_assignable<json_value>::value
21716 other.set_parents();
21717 assert_invariant();
21723 std::is_nothrow_move_constructible<value_t>::value&&
21724 std::is_nothrow_move_assignable<value_t>::value&&
21725 std::is_nothrow_move_constructible<json_value>::value&&
21726 std::is_nothrow_move_assignable<json_value>::value
21818#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
21819 const auto lhs_type = lhs.type(); \
21820 const auto rhs_type = rhs.type(); \
21822 if (lhs_type == rhs_type) \
21824 switch (lhs_type) \
21826 case value_t::array: \
21827 return (*lhs.m_value.array) op (*rhs.m_value.array); \
21829 case value_t::object: \
21830 return (*lhs.m_value.object) op (*rhs.m_value.object); \
21832 case value_t::null: \
21833 return (null_result); \
21835 case value_t::string: \
21836 return (*lhs.m_value.string) op (*rhs.m_value.string); \
21838 case value_t::boolean: \
21839 return (lhs.m_value.boolean) op (rhs.m_value.boolean); \
21841 case value_t::number_integer: \
21842 return (lhs.m_value.number_integer) op (rhs.m_value.number_integer); \
21844 case value_t::number_unsigned: \
21845 return (lhs.m_value.number_unsigned) op (rhs.m_value.number_unsigned); \
21847 case value_t::number_float: \
21848 return (lhs.m_value.number_float) op (rhs.m_value.number_float); \
21850 case value_t::binary: \
21851 return (*lhs.m_value.binary) op (*rhs.m_value.binary); \
21853 case value_t::discarded: \
21855 return (unordered_result); \
21858 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
21860 return static_cast<number_float_t>(lhs.m_value.number_integer) op rhs.m_value.number_float; \
21862 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
21864 return lhs.m_value.number_float op static_cast<number_float_t>(rhs.m_value.number_integer); \
21866 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
21868 return static_cast<number_float_t>(lhs.m_value.number_unsigned) op rhs.m_value.number_float; \
21870 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
21872 return lhs.m_value.number_float op static_cast<number_float_t>(rhs.m_value.number_unsigned); \
21874 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
21876 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) op rhs.m_value.number_integer; \
21878 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
21880 return lhs.m_value.number_integer op static_cast<number_integer_t>(rhs.m_value.number_unsigned); \
21882 else if(compares_unordered(lhs, rhs))\
21884 return (unordered_result);\
21887 return (default_result);
21902#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
21913 return compares_unordered(*
this,
rhs,
inverse);
21917#if JSON_HAS_THREE_WAY_COMPARISON
21923#pragma GCC diagnostic push
21924#pragma GCC diagnostic ignored "-Wfloat-equal"
21929#pragma GCC diagnostic pop
21935 template<
typename ScalarType>
21936 requires std::is_scalar_v<ScalarType>
21946 if (compares_unordered(
rhs,
true))
21961 std::partial_ordering::equivalent,
21962 std::partial_ordering::unordered,
21963 lhs_type <=> rhs_type)
21968 template<
typename ScalarType>
21969 requires std::is_scalar_v<ScalarType>
21970 std::partial_ordering operator<=>(ScalarType
rhs)
const noexcept
21975#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
21984 if (compares_unordered(
rhs,
true))
21988 return !(
rhs < *
this);
21993 template<
typename ScalarType>
21994 requires std::is_scalar_v<ScalarType>
21995 bool operator<=(ScalarType
rhs)
const noexcept
22005 if (compares_unordered(
rhs,
true))
22009 return !(*
this <
rhs);
22014 template<
typename ScalarType>
22015 requires std::is_scalar_v<ScalarType>
22016 bool operator>=(ScalarType
rhs)
const noexcept
22027#pragma GCC diagnostic push
22028#pragma GCC diagnostic ignored "-Wfloat-equal"
22032#pragma GCC diagnostic pop
22038 template<
typename ScalarType,
typename std::enable_if<
22039 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22047 template<
typename ScalarType,
typename std::enable_if<
22048 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22058 if (compares_unordered(lhs,
rhs,
true))
22062 return !(lhs ==
rhs);
22067 template<
typename ScalarType,
typename std::enable_if<
22068 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22076 template<
typename ScalarType,
typename std::enable_if<
22077 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22095 template<
typename ScalarType,
typename std::enable_if<
22096 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22104 template<
typename ScalarType,
typename std::enable_if<
22105 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22115 if (compares_unordered(lhs,
rhs,
true))
22119 return !(
rhs < lhs);
22124 template<
typename ScalarType,
typename std::enable_if<
22125 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22133 template<
typename ScalarType,
typename std::enable_if<
22134 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22145 if (compares_unordered(lhs,
rhs))
22149 return !(lhs <=
rhs);
22154 template<
typename ScalarType,
typename std::enable_if<
22155 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22163 template<
typename ScalarType,
typename std::enable_if<
22164 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22174 if (compares_unordered(lhs,
rhs,
true))
22178 return !(lhs <
rhs);
22183 template<
typename ScalarType,
typename std::enable_if<
22184 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22192 template<
typename ScalarType,
typename std::enable_if<
22193 std::is_scalar<ScalarType>::value,
int>
::type = 0>
22200#undef JSON_IMPLEMENT_OPERATOR
22216 const bool pretty_print = o.width() > 0;
22217 const auto indentation = pretty_print ? o.width() : 0;
22223 serializer s(detail::output_adapter<char>(o), o.fill());
22224 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
22252 template<
typename InputType>
22256 const bool allow_exceptions =
true,
22257 const bool ignore_comments =
false)
22260 parser(
detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(
true, result);
22266 template<
typename IteratorType>
22271 const bool allow_exceptions =
true,
22272 const bool ignore_comments =
false)
22275 parser(
detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(
true, result);
22281 static basic_json parse(detail::span_input_adapter&& i,
22283 const bool allow_exceptions =
true,
22284 const bool ignore_comments =
false)
22287 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
22293 template<
typename InputType>
22294 static bool accept(InputType&& i,
22295 const bool ignore_comments =
false)
22297 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
22302 template<
typename IteratorType>
22303 static bool accept(IteratorType first, IteratorType last,
22304 const bool ignore_comments =
false)
22306 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
22311 static bool accept(detail::span_input_adapter&& i,
22312 const bool ignore_comments =
false)
22314 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
22319 template <
typename InputType,
typename SAX>
22323 const
bool strict = true,
22324 const
bool ignore_comments = false)
22328 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22334 template<
class IteratorType,
class SAX>
22336 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
22338 const
bool strict = true,
22339 const
bool ignore_comments = false)
22343 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22352 template <
typename SAX>
22357 const
bool strict = true,
22358 const
bool ignore_comments = false)
22363 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22414 return "discarded";
22435#if JSON_DIAGNOSTICS
22452 std::vector<std::uint8_t> result;
22475 std::vector<std::uint8_t> result;
22497 const bool use_size =
false,
22498 const bool use_type =
false)
22500 std::vector<std::uint8_t> result;
22501 to_ubjson(j, result, use_size, use_type);
22508 const bool use_size =
false,
const bool use_type =
false)
22516 const bool use_size =
false,
const bool use_type =
false)
22524 const bool use_size =
false,
22525 const bool use_type =
false)
22527 std::vector<std::uint8_t> result;
22528 to_bjdata(j, result, use_size, use_type);
22535 const bool use_size =
false,
const bool use_type =
false)
22543 const bool use_size =
false,
const bool use_type =
false)
22552 std::vector<std::uint8_t> result;
22573 template<
typename InputType>
22576 const bool strict =
true,
22577 const bool allow_exceptions =
true,
22589 template<
typename IteratorType>
22592 const bool strict =
true,
22593 const bool allow_exceptions =
true,
22603 template<
typename T>
22607 const
bool strict = true,
22608 const
bool allow_exceptions = true,
22611 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
22618 const
bool strict = true,
22619 const
bool allow_exceptions = true,
22632 template<
typename InputType>
22635 const bool strict =
true,
22636 const bool allow_exceptions =
true)
22647 template<
typename IteratorType>
22650 const bool strict =
true,
22651 const bool allow_exceptions =
true)
22660 template<
typename T>
22664 const
bool strict = true,
22665 const
bool allow_exceptions = true)
22667 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
22673 const
bool strict = true,
22674 const
bool allow_exceptions = true)
22686 template<
typename InputType>
22689 const bool strict =
true,
22690 const bool allow_exceptions =
true)
22701 template<
typename IteratorType>
22704 const bool strict =
true,
22705 const bool allow_exceptions =
true)
22714 template<
typename T>
22718 const
bool strict = true,
22719 const
bool allow_exceptions = true)
22721 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
22727 const
bool strict = true,
22728 const
bool allow_exceptions = true)
22741 template<
typename InputType>
22744 const bool strict =
true,
22745 const bool allow_exceptions =
true)
22756 template<
typename IteratorType>
22759 const bool strict =
true,
22760 const bool allow_exceptions =
true)
22771 template<
typename InputType>
22774 const bool strict =
true,
22775 const bool allow_exceptions =
true)
22786 template<
typename IteratorType>
22789 const bool strict =
true,
22790 const bool allow_exceptions =
true)
22799 template<
typename T>
22803 const
bool strict = true,
22804 const
bool allow_exceptions = true)
22806 return from_bson(ptr, ptr + len, strict, allow_exceptions);
22812 const
bool strict = true,
22813 const
bool allow_exceptions = true)
22835 return ptr.get_unchecked(
this);
22838 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22842 return ptr.get_unchecked(
this);
22849 return ptr.get_unchecked(
this);
22852 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22856 return ptr.get_unchecked(
this);
22863 return ptr.get_checked(
this);
22866 template<
typename BasicJsonType>
22868 reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
22870 return ptr.get_checked(
this);
22877 return ptr.get_checked(
this);
22880 template<
typename BasicJsonType>
22884 return ptr.get_checked(
this);
22892 json_pointer::flatten(
"", *
this, result);
22900 return json_pointer::unflatten(*
this);
22920 enum class patch_operations { add, remove,
replace, move, copy, test, invalid };
22922 const auto get_op = [](
const std::string& op)
22926 return patch_operations::add;
22928 if (op ==
"remove")
22930 return patch_operations::remove;
22932 if (op ==
"replace")
22934 return patch_operations::replace;
22938 return patch_operations::move;
22942 return patch_operations::copy;
22946 return patch_operations::test;
22949 return patch_operations::invalid;
22964 if (top_pointer != ptr)
22966 result.at(top_pointer);
22970 const auto last_path = ptr.back();
22974 switch (parent.m_type)
22980 parent[last_path] = val;
22986 if (last_path ==
"-")
22989 parent.push_back(val);
22993 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
23001 parent.insert(parent.begin() +
static_cast<difference_type>(idx), val);
23020 const auto operation_remove = [
this, &result](
json_pointer& ptr)
23023 const auto last_path = ptr.back();
23028 if (parent.is_object())
23031 auto it = parent.find(last_path);
23041 else if (parent.is_array())
23044 parent.erase(json_pointer::template array_index<basic_json_t>(last_path));
23055 for (
const auto& val : json_patch)
23058 const auto get_value = [&val](
const std::string& op,
23059 const std::string& member,
23063 auto it = val.m_value.object->find(member);
23066 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
23093 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
23094 const auto path = get_value(op,
"path",
true).template get<std::string>();
23097 switch (get_op(op))
23099 case patch_operations::add:
23101 operation_add(ptr, get_value(
"add",
"value",
false));
23105 case patch_operations::remove:
23107 operation_remove(ptr);
23111 case patch_operations::replace:
23114 result.at(ptr) = get_value(
"replace",
"value",
false);
23118 case patch_operations::move:
23120 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
23130 operation_remove(from_ptr);
23131 operation_add(ptr, v);
23135 case patch_operations::copy:
23137 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
23146 operation_add(ptr, v);
23150 case patch_operations::test:
23152 bool success =
false;
23157 success = (result.at(ptr) == get_value(
"test",
"value",
false));
23173 case patch_operations::invalid:
23190 const std::string& path =
"")
23196 if (source == target)
23201 if (source.type() != target.type())
23206 {
"op",
"replace"}, {
"path", path}, {
"value", target}
23211 switch (source.type())
23217 while (i < source.size() && i < target.size())
23221 result.insert(result.end(), temp_diff.begin(), temp_diff.end());
23230 while (i < source.size())
23234 result.insert(result.begin() + end_index,
object(
23243 while (i < target.size())
23249 {
"value", target[i]}
23260 for (
auto it = source.cbegin(); it != source.cend(); ++it)
23265 if (target.find(it.key()) != target.end())
23268 auto temp_diff = diff(it.value(), target[it.key()], path_key);
23269 result.insert(result.end(), temp_diff.begin(), temp_diff.end());
23274 result.push_back(
object(
23276 {
"op",
"remove"}, {
"path", path_key}
23282 for (
auto it = target.cbegin(); it != target.cend(); ++it)
23284 if (source.find(it.key()) == source.end())
23290 {
"op",
"add"}, {
"path", path_key},
23291 {
"value", it.value()}
23312 {
"op",
"replace"}, {
"path", path}, {
"value", target}
23340 for (
auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
23342 if (it.value().is_null())
23354 *
this = apply_patch;
23400#if JSON_HAS_THREE_WAY_COMPARISON
23401 return std::is_lt(lhs <=> rhs);
23409#ifndef JSON_HAS_CPP_20
23415 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
23416 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
23430 return nlohmann::json::parse(s, s + n);
23445#if defined(__clang__)
23446#pragma clang diagnostic pop
23451#undef JSON_INTERNAL_CATCH
23453#undef JSON_PRIVATE_UNLESS_TESTED
23454#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
23455#undef NLOHMANN_BASIC_JSON_TPL
23456#undef JSON_EXPLICIT
23457#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
23458#undef JSON_INLINE_VARIABLE
23459#undef JSON_NO_UNIQUE_ADDRESS
23461#ifndef JSON_TEST_KEEP_MACROS
23464#undef JSON_HAS_CPP_11
23465#undef JSON_HAS_CPP_14
23466#undef JSON_HAS_CPP_17
23467#undef JSON_HAS_CPP_20
23468#undef JSON_HAS_FILESYSTEM
23469#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
23470#undef JSON_HAS_THREE_WAY_COMPARISON
23471#undef JSON_HAS_RANGES
23472#undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23478#undef JSON_HEDLEY_ALWAYS_INLINE
23479#undef JSON_HEDLEY_ARM_VERSION
23480#undef JSON_HEDLEY_ARM_VERSION_CHECK
23481#undef JSON_HEDLEY_ARRAY_PARAM
23482#undef JSON_HEDLEY_ASSUME
23483#undef JSON_HEDLEY_BEGIN_C_DECLS
23484#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
23485#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
23486#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
23487#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
23488#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
23489#undef JSON_HEDLEY_CLANG_HAS_FEATURE
23490#undef JSON_HEDLEY_CLANG_HAS_WARNING
23491#undef JSON_HEDLEY_COMPCERT_VERSION
23492#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
23493#undef JSON_HEDLEY_CONCAT
23494#undef JSON_HEDLEY_CONCAT3
23495#undef JSON_HEDLEY_CONCAT3_EX
23496#undef JSON_HEDLEY_CONCAT_EX
23497#undef JSON_HEDLEY_CONST
23498#undef JSON_HEDLEY_CONSTEXPR
23499#undef JSON_HEDLEY_CONST_CAST
23500#undef JSON_HEDLEY_CPP_CAST
23501#undef JSON_HEDLEY_CRAY_VERSION
23502#undef JSON_HEDLEY_CRAY_VERSION_CHECK
23503#undef JSON_HEDLEY_C_DECL
23504#undef JSON_HEDLEY_DEPRECATED
23505#undef JSON_HEDLEY_DEPRECATED_FOR
23506#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
23507#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
23508#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
23509#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
23510#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
23511#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
23512#undef JSON_HEDLEY_DIAGNOSTIC_POP
23513#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
23514#undef JSON_HEDLEY_DMC_VERSION
23515#undef JSON_HEDLEY_DMC_VERSION_CHECK
23516#undef JSON_HEDLEY_EMPTY_BASES
23517#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
23518#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
23519#undef JSON_HEDLEY_END_C_DECLS
23520#undef JSON_HEDLEY_FLAGS
23521#undef JSON_HEDLEY_FLAGS_CAST
23522#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
23523#undef JSON_HEDLEY_GCC_HAS_BUILTIN
23524#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
23525#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
23526#undef JSON_HEDLEY_GCC_HAS_EXTENSION
23527#undef JSON_HEDLEY_GCC_HAS_FEATURE
23528#undef JSON_HEDLEY_GCC_HAS_WARNING
23529#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
23530#undef JSON_HEDLEY_GCC_VERSION
23531#undef JSON_HEDLEY_GCC_VERSION_CHECK
23532#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
23533#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
23534#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
23535#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
23536#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
23537#undef JSON_HEDLEY_GNUC_HAS_FEATURE
23538#undef JSON_HEDLEY_GNUC_HAS_WARNING
23539#undef JSON_HEDLEY_GNUC_VERSION
23540#undef JSON_HEDLEY_GNUC_VERSION_CHECK
23541#undef JSON_HEDLEY_HAS_ATTRIBUTE
23542#undef JSON_HEDLEY_HAS_BUILTIN
23543#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
23544#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
23545#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
23546#undef JSON_HEDLEY_HAS_EXTENSION
23547#undef JSON_HEDLEY_HAS_FEATURE
23548#undef JSON_HEDLEY_HAS_WARNING
23549#undef JSON_HEDLEY_IAR_VERSION
23550#undef JSON_HEDLEY_IAR_VERSION_CHECK
23551#undef JSON_HEDLEY_IBM_VERSION
23552#undef JSON_HEDLEY_IBM_VERSION_CHECK
23553#undef JSON_HEDLEY_IMPORT
23554#undef JSON_HEDLEY_INLINE
23555#undef JSON_HEDLEY_INTEL_CL_VERSION
23556#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
23557#undef JSON_HEDLEY_INTEL_VERSION
23558#undef JSON_HEDLEY_INTEL_VERSION_CHECK
23559#undef JSON_HEDLEY_IS_CONSTANT
23560#undef JSON_HEDLEY_IS_CONSTEXPR_
23561#undef JSON_HEDLEY_LIKELY
23562#undef JSON_HEDLEY_MALLOC
23563#undef JSON_HEDLEY_MCST_LCC_VERSION
23564#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
23565#undef JSON_HEDLEY_MESSAGE
23566#undef JSON_HEDLEY_MSVC_VERSION
23567#undef JSON_HEDLEY_MSVC_VERSION_CHECK
23568#undef JSON_HEDLEY_NEVER_INLINE
23569#undef JSON_HEDLEY_NON_NULL
23570#undef JSON_HEDLEY_NO_ESCAPE
23571#undef JSON_HEDLEY_NO_RETURN
23572#undef JSON_HEDLEY_NO_THROW
23573#undef JSON_HEDLEY_NULL
23574#undef JSON_HEDLEY_PELLES_VERSION
23575#undef JSON_HEDLEY_PELLES_VERSION_CHECK
23576#undef JSON_HEDLEY_PGI_VERSION
23577#undef JSON_HEDLEY_PGI_VERSION_CHECK
23578#undef JSON_HEDLEY_PREDICT
23579#undef JSON_HEDLEY_PRINTF_FORMAT
23580#undef JSON_HEDLEY_PRIVATE
23581#undef JSON_HEDLEY_PUBLIC
23582#undef JSON_HEDLEY_PURE
23583#undef JSON_HEDLEY_REINTERPRET_CAST
23584#undef JSON_HEDLEY_REQUIRE
23585#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
23586#undef JSON_HEDLEY_REQUIRE_MSG
23587#undef JSON_HEDLEY_RESTRICT
23588#undef JSON_HEDLEY_RETURNS_NON_NULL
23589#undef JSON_HEDLEY_SENTINEL
23590#undef JSON_HEDLEY_STATIC_ASSERT
23591#undef JSON_HEDLEY_STATIC_CAST
23592#undef JSON_HEDLEY_STRINGIFY
23593#undef JSON_HEDLEY_STRINGIFY_EX
23594#undef JSON_HEDLEY_SUNPRO_VERSION
23595#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
23596#undef JSON_HEDLEY_TINYC_VERSION
23597#undef JSON_HEDLEY_TINYC_VERSION_CHECK
23598#undef JSON_HEDLEY_TI_ARMCL_VERSION
23599#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
23600#undef JSON_HEDLEY_TI_CL2000_VERSION
23601#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
23602#undef JSON_HEDLEY_TI_CL430_VERSION
23603#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
23604#undef JSON_HEDLEY_TI_CL6X_VERSION
23605#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
23606#undef JSON_HEDLEY_TI_CL7X_VERSION
23607#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
23608#undef JSON_HEDLEY_TI_CLPRU_VERSION
23609#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
23610#undef JSON_HEDLEY_TI_VERSION
23611#undef JSON_HEDLEY_TI_VERSION_CHECK
23612#undef JSON_HEDLEY_UNAVAILABLE
23613#undef JSON_HEDLEY_UNLIKELY
23614#undef JSON_HEDLEY_UNPREDICTABLE
23615#undef JSON_HEDLEY_UNREACHABLE
23616#undef JSON_HEDLEY_UNREACHABLE_RETURN
23617#undef JSON_HEDLEY_VERSION
23618#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
23619#undef JSON_HEDLEY_VERSION_DECODE_MINOR
23620#undef JSON_HEDLEY_VERSION_DECODE_REVISION
23621#undef JSON_HEDLEY_VERSION_ENCODE
23622#undef JSON_HEDLEY_WARNING
23623#undef JSON_HEDLEY_WARN_UNUSED_RESULT
23624#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
23625#undef JSON_HEDLEY_FALL_THROUGH
nlohmann::json json
Definition: GameObjectFactory.cpp:10
a class to store JSON values
Definition: json.hpp:18399
ValueType & get_to(ValueType &v) const
Definition: json.hpp:20100
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
Definition: json.hpp:21626
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
Definition: json.hpp:19095
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:22847
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.hpp:22833
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
Definition: json.hpp:19639
const_reference operator[](T *key) const
Definition: json.hpp:20453
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:18656
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:21651
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition: json.hpp:22523
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
Definition: json.hpp:18465
ReferenceType get_ref()
get a reference value (implicit)
Definition: json.hpp:20123
reference emplace_back(Args &&... args)
add an object to an array
Definition: json.hpp:21452
basic_json(const value_t v)
create an empty value with a given type
Definition: json.hpp:19108
iterator find(KeyType &&key)
find an element in a JSON object
Definition: json.hpp:20921
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
Definition: json.hpp:22550
value_type & reference
the type of an element reference
Definition: json.hpp:18510
void erase(const size_type idx)
remove element from a JSON array given an index
Definition: json.hpp:20861
detail::out_of_range out_of_range
Definition: json.hpp:18491
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition: json.hpp:20312
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition: json.hpp:20274
binary_t & get_binary()
get a binary value
Definition: json.hpp:20193
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition: json.hpp:19322
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:22473
basic_json(const JsonRef &ref)
Definition: json.hpp:19432
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition: json.hpp:22450
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
copy assignment
Definition: json.hpp:19521
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition: json.hpp:19294
reference back()
access the last element
Definition: json.hpp:20647
const binary_t & get_binary() const
get a binary value
Definition: json.hpp:20205
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition: json.hpp:22542
StringType string_t
a type for a string
Definition: json.hpp:18648
void push_back(const basic_json &val)
add an object to an array
Definition: json.hpp:21364
reference at(KeyType &&key)
access specified object element with bounds checking
Definition: json.hpp:20294
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition: json.hpp:18549
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition: json.hpp:20587
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
Definition: json.hpp:18640
std::size_t size_type
a type to represent container sizes
Definition: json.hpp:18517
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition: json.hpp:20087
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition: json.hpp:18515
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition: json.hpp:19250
reference operator+=(basic_json &&val)
add an object to an array
Definition: json.hpp:21356
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition: json.hpp:19142
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
Definition: json.hpp:18525
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition: json.hpp:22788
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:20951
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition: json.hpp:22743
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
Definition: json.hpp:18523
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition: json.hpp:22575
BooleanType boolean_t
a type for a boolean
Definition: json.hpp:18652
void push_back(initializer_list_t init)
add an object to an object
Definition: json.hpp:21427
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition: json.hpp:19561
reference operator[](typename object_t::key_type key)
access specified object element
Definition: json.hpp:20409
std::decay< ValueType >::type value(KeyType &&key, ValueType &&default_value) const
access specified object element with default value
Definition: json.hpp:20555
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition: json.hpp:20668
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
Definition: json.hpp:20905
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
Definition: json.hpp:22559
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition: json.hpp:22773
constexpr bool is_structured() const noexcept
return whether type is structured
Definition: json.hpp:19597
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:21658
JSON_PRIVATE_UNLESS_TESTED const_reference bool static SAX bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
Definition: json.hpp:22321
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:20228
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition: json.hpp:19283
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition: json.hpp:19590
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition: json.hpp:19632
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
Definition: json.hpp:22466
void swap(object_t &other)
exchanges the values
Definition: json.hpp:21749
constexpr bool is_object() const noexcept
return whether value is an object
Definition: json.hpp:19646
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
Definition: json.hpp:20978
reference operator[](KeyType &&key)
access specified object element
Definition: json.hpp:20462
const_reference front() const
access the first element
Definition: json.hpp:20640
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition: json.hpp:19583
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:18664
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
Definition: json.hpp:18532
basic_json(const basic_json &other)
copy constructor
Definition: json.hpp:19436
~basic_json() noexcept
destructor
Definition: json.hpp:19542
const_iterator find(KeyType &&key) const
find an element in a JSON object
Definition: json.hpp:20937
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:22496
basic_json(basic_json &&other) noexcept
move constructor
Definition: json.hpp:19504
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
Definition: json.hpp:20969
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:22515
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
Definition: json.hpp:21555
json_value m_value
the value of the current element
Definition: json.hpp:22433
void swap(typename binary_t::container_type &other)
exchanges the values
Definition: json.hpp:21794
void swap(array_t &other)
exchanges the values
Definition: json.hpp:21734
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition: json.hpp:19261
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
Definition: json.hpp:18631
ReferenceType get_ref() const
get a reference value (implicit)
Definition: json.hpp:20134
const_reference at(KeyType &&key) const
access specified object element with bounds checking
Definition: json.hpp:20332
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
Definition: json.hpp:21575
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition: json.hpp:20074
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:22875
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition: json.hpp:23332
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:19834
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
Definition: json.hpp:21606
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition: json.hpp:18644
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition: json.hpp:20111
const_reference operator[](KeyType &&key) const
access specified object element
Definition: json.hpp:20486
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition: json.hpp:20738
constexpr bool is_boolean() const noexcept
return whether value is a boolean
Definition: json.hpp:19611
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:21705
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:22649
constexpr bool is_binary() const noexcept
return whether value is a binary array
Definition: json.hpp:19667
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) const _reference operator[](const
access specified element via JSON Pointer
Definition: json.hpp:22853
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition: json.hpp:19302
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
Definition: json.hpp:21548
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition: json.hpp:22703
reference operator[](size_type idx)
access specified array element
Definition: json.hpp:20350
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
Definition: json.hpp:22566
std::decay< ValueType >::type value(const char *key, ValueType &&default_value) const
Definition: json.hpp:20538
string_t value(KeyType &&key, const char *default_value) const
access specified object element with default value
Definition: json.hpp:20578
void swap(binary_t &other)
exchanges the values
Definition: json.hpp:21779
iter_impl< basic_json > iterator
an iterator for a basic_json container
Definition: json.hpp:18528
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
Definition: json.hpp:18534
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition: json.hpp:22688
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:22507
string_t value(const char *key, const char *default_value) const
Definition: json.hpp:20543
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:20961
void swap(string_t &other)
exchanges the values
Definition: json.hpp:21764
const_reference back() const
access the last element
Definition: json.hpp:20656
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
Definition: json.hpp:19272
constexpr bool is_string() const noexcept
return whether value is a string
Definition: json.hpp:19660
constexpr bool is_array() const noexcept
return whether value is an array
Definition: json.hpp:19653
iterator insert_iterator(const_iterator pos, Args &&... args)
Definition: json.hpp:21509
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) ValueType value(const
access specified object element via JSON Pointer with default value
Definition: json.hpp:20608
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
Definition: json.hpp:22397
const value_type & const_reference
the type of an element const reference
Definition: json.hpp:18512
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition: json.hpp:22591
reference operator[](T *key)
Definition: json.hpp:20447
constexpr bool is_number() const noexcept
return whether value is a number
Definition: json.hpp:19618
reference operator+=(initializer_list_t init)
add an object to an object
Definition: json.hpp:21443
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
Definition: json.hpp:19625
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
Definition: json.hpp:18473
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
Definition: json.hpp:22459
detail::value_t value_t
Definition: json.hpp:18463
size_type erase(KeyType &&key)
remove element from a JSON object given a key
Definition: json.hpp:20854
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:22489
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
Definition: json.hpp:20431
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
Definition: json.hpp:18672
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition: json.hpp:19116
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition: json.hpp:22758
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference operator[](const
Definition: json.hpp:22839
const_reference operator[](size_type idx) const
access specified array element
Definition: json.hpp:20396
AllocatorType< basic_json > allocator_type
the allocator type
Definition: json.hpp:18520
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
Definition: json.hpp:18668
JSONSerializer< T, SFINAE > json_serializer
Definition: json.hpp:18467
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:21396
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference at(const
Definition: json.hpp:22867
JSON_PRIVATE_UNLESS_TESTED const_reference rhs
Definition: json.hpp:21895
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition: json.hpp:20985
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:22634
string_t value(const typename object_t::key_type &key, const char *default_value) const
access specified object element with default value
Definition: json.hpp:20527
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
Definition: json.hpp:19128
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
Definition: json.hpp:18660
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
Definition: json.hpp:20891
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:21419
std::decay< ValueType >::type value(const KeyType &key, ValueType &&default_value) const
access specified object element with default value
Definition: json.hpp:20506
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
Definition: json.hpp:22382
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
Definition: json.hpp:19194
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition: json.hpp:20251
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
Definition: json.hpp:21528
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
Definition: json.hpp:18530
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition: json.hpp:19674
constexpr bool is_null() const noexcept
return whether value is null
Definition: json.hpp:19604
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:21722
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition: json.hpp:22534
JSON_PRIVATE_UNLESS_TESTED const_reference bool inverse
Definition: json.hpp:21895
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
Definition: json.hpp:20033
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition: json.hpp:21477
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:22482
reference operator+=(const basic_json &val)
add an object to an array
Definition: json.hpp:21388
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition: json.hpp:20843
friend std::istream & operator<<(basic_json &j, std::istream &i)
deserialize from stream
Definition: json.hpp:22375
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition: json.hpp:19309
static allocator_type get_allocator()
returns the allocator associated with the container
Definition: json.hpp:18541
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:19845
an internal type for a backed binary type
Definition: json.hpp:5382
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
Definition: json.hpp:5403
BinaryType container_type
Definition: json.hpp:5384
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
Definition: json.hpp:5393
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:5398
bool operator!=(const byte_container_with_subtype &rhs) const
Definition: json.hpp:5422
void clear_subtype() noexcept
clears the binary subtype
Definition: json.hpp:5451
byte_container_with_subtype() noexcept(noexcept(container_type()))
Definition: json.hpp:5388
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:5410
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
Definition: json.hpp:5444
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
Definition: json.hpp:5429
constexpr subtype_type subtype() const noexcept
return the binary subtype
Definition: json.hpp:5437
std::uint64_t subtype_type
Definition: json.hpp:5385
bool operator==(const byte_container_with_subtype &rhs) const
Definition: json.hpp:5416
deserialization of CBOR, MessagePack, and UBJSON values
Definition: json.hpp:8652
binary_reader & operator=(const binary_reader &)=delete
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
Definition: json.hpp:8668
binary_reader & operator=(binary_reader &&)=default
binary_reader(const binary_reader &)=delete
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
Definition: json.hpp:8689
binary_reader(binary_reader &&)=default
serialization to CBOR and MessagePack values
Definition: json.hpp:14220
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false)
Definition: json.hpp:14919
static constexpr CharType to_char_type(InputCharType x) noexcept
Definition: json.hpp:16004
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
Definition: json.hpp:14231
static CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:15982
void write_bson(const BasicJsonType &j)
Definition: json.hpp:14240
void write_cbor(const BasicJsonType &j)
Definition: json.hpp:14269
static constexpr CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:15975
void write_msgpack(const BasicJsonType &j)
Definition: json.hpp:14593
general exception of the basic_json class
Definition: json.hpp:3931
const int id
the id of the exception
Definition: json.hpp:3940
static std::string diagnostics(std::nullptr_t)
Definition: json.hpp:3951
static std::string diagnostics(const BasicJsonType *leaf_element)
Definition: json.hpp:3957
static std::string name(const std::string &ename, int id_)
Definition: json.hpp:3946
const char * what() const noexcept override
returns the explanatory string
Definition: json.hpp:3934
exception indicating errors with iterators
Definition: json.hpp:4082
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4085
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
Definition: json.hpp:12250
bool operator<(const iter_impl &other) const
comparison: smaller
Definition: json.hpp:12716
iter_impl operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:12846
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition: json.hpp:12707
void set_end() noexcept
set the iterator past the last value
Definition: json.hpp:12443
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition: json.hpp:12280
iter_impl & operator--()
pre-decrement (–it)
Definition: json.hpp:12630
difference_type operator-(const iter_impl &other) const
return difference
Definition: json.hpp:12857
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition: json.hpp:12362
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
Definition: json.hpp:12289
reference operator*() const
return a reference to the value pointed to by the iterator
Definition: json.hpp:12482
iter_impl(iter_impl &&) noexcept=default
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition: json.hpp:12769
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
Definition: json.hpp:12284
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition: json.hpp:12387
pointer operator->() const
dereference the iterator
Definition: json.hpp:12526
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition: json.hpp:12352
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition: json.hpp:12377
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:12949
iter_impl operator+(difference_type i) const
add to iterator
Definition: json.hpp:12824
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition: json.hpp:12835
const object_t::key_type & key() const
return the key of an object iterator
Definition: json.hpp:12924
bool operator==(const IterImpl &other) const
comparison: equal
Definition: json.hpp:12671
bool operator>(const iter_impl &other) const
comparison: greater than
Definition: json.hpp:12760
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
Definition: json.hpp:12278
reference value() const
return the value of an iterator
Definition: json.hpp:12940
iter_impl & operator++()
pre-increment (++it)
Definition: json.hpp:12579
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:12886
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition: json.hpp:12751
iter_impl operator++(int) &
post-increment (it++)
Definition: json.hpp:12568
std::bidirectional_iterator_tag iterator_category
Definition: json.hpp:12275
iter_impl operator--(int) &
post-decrement (it–)
Definition: json.hpp:12619
iter_impl & operator+=(difference_type i)
add to iterator
Definition: json.hpp:12778
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition: json.hpp:12815
Definition: json.hpp:4694
std::input_iterator_tag iterator_category
Definition: json.hpp:4700
iteration_proxy_value(iteration_proxy_value const &)=default
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
Definition: json.hpp:4765
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
Definition: json.hpp:4717
iteration_proxy_value operator++(int) &
Definition: json.hpp:4750
iteration_proxy_value()=default
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
Definition: json.hpp:4701
IteratorType::reference value() const
return value of the iterator
Definition: json.hpp:4807
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
Definition: json.hpp:4742
std::ptrdiff_t difference_type
Definition: json.hpp:4696
const string_type & key() const
return key of the iterator
Definition: json.hpp:4771
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
Definition: json.hpp:4759
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
proxy class for the items() function
Definition: json.hpp:4815
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
Definition: json.hpp:4834
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
Definition: json.hpp:4840
iteration_proxy()=default
iteration_proxy & operator=(iteration_proxy const &)=default
iteration_proxy(iteration_proxy const &)=default
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition: json.hpp:4824
Definition: json.hpp:13979
json_ref(json_ref &&) noexcept=default
value_type const & operator*() const
Definition: json.hpp:14018
BasicJsonType value_type
Definition: json.hpp:13981
json_ref(Args &&... args)
Definition: json.hpp:13998
json_ref(const value_type &value)
Definition: json.hpp:13987
value_type const * operator->() const
Definition: json.hpp:14023
json_ref(std::initializer_list< json_ref > init)
Definition: json.hpp:13991
json_ref(value_type &&value)
Definition: json.hpp:13983
value_type moved_or_copied() const
Definition: json.hpp:14009
a template for a reverse iterator class
Definition: json.hpp:12991
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition: json.hpp:13000
typename Base::reference reference
the reference type for the pointed-to element
Definition: json.hpp:12997
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:13043
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition: json.hpp:13031
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition: json.hpp:12995
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition: json.hpp:13004
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:13055
json_reverse_iterator operator--(int) &
post-decrement (it–)
Definition: json.hpp:13019
std::ptrdiff_t difference_type
Definition: json.hpp:12993
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition: json.hpp:13049
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition: json.hpp:13037
json_reverse_iterator operator++(int) &
post-increment (it++)
Definition: json.hpp:13007
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition: json.hpp:13061
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition: json.hpp:13025
reference value() const
return the value of an iterator
Definition: json.hpp:13068
json_reverse_iterator & operator++()
pre-increment (++it)
Definition: json.hpp:13013
Definition: json.hpp:6751
bool end_array()
Definition: json.hpp:6814
bool start_object(std::size_t=static_cast< std::size_t >(-1))
Definition: json.hpp:6794
typename BasicJsonType::string_t string_t
Definition: json.hpp:6756
bool binary(binary_t &)
Definition: json.hpp:6789
bool boolean(bool)
Definition: json.hpp:6764
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6753
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6755
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6757
bool key(string_t &)
Definition: json.hpp:6799
bool end_object()
Definition: json.hpp:6804
bool start_array(std::size_t=static_cast< std::size_t >(-1))
Definition: json.hpp:6809
bool parse_error(std::size_t, const std::string &, const detail::exception &)
Definition: json.hpp:6819
bool number_integer(number_integer_t)
Definition: json.hpp:6769
bool string(string_t &)
Definition: json.hpp:6784
bool number_unsigned(number_unsigned_t)
Definition: json.hpp:6774
bool null()
Definition: json.hpp:6759
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6754
bool number_float(number_float_t, const string_t &)
Definition: json.hpp:6779
Definition: json.hpp:6444
typename BasicJsonType::string_t string_t
Definition: json.hpp:6449
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
bool start_object(std::size_t len)
Definition: json.hpp:6511
bool key(string_t &val)
Definition: json.hpp:6529
constexpr bool is_errored() const
Definition: json.hpp:6644
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6447
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6446
bool null()
Definition: json.hpp:6469
typename BasicJsonType::parser_callback_t parser_callback_t
Definition: json.hpp:6451
bool start_array(std::size_t len)
Definition: json.hpp:6582
~json_sax_dom_callback_parser()=default
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6450
bool binary(binary_t &val)
Definition: json.hpp:6505
bool number_integer(number_integer_t val)
Definition: json.hpp:6481
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6448
bool end_array()
Definition: json.hpp:6599
typename BasicJsonType::parse_event_t parse_event_t
Definition: json.hpp:6452
bool boolean(bool val)
Definition: json.hpp:6475
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:6487
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
bool string(string_t &val)
Definition: json.hpp:6499
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:6493
bool end_object()
Definition: json.hpp:6546
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:6632
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
Definition: json.hpp:6454
SAX implementation to create a JSON value from SAX events.
Definition: json.hpp:6261
bool start_array(std::size_t len)
Definition: json.hpp:6359
json_sax_dom_parser(const json_sax_dom_parser &)=delete
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6267
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:6303
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6263
bool boolean(bool val)
Definition: json.hpp:6291
~json_sax_dom_parser()=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:6382
bool string(string_t &val)
Definition: json.hpp:6315
bool end_object()
Definition: json.hpp:6349
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6264
bool start_object(std::size_t len)
Definition: json.hpp:6327
bool null()
Definition: json.hpp:6285
bool binary(binary_t &val)
Definition: json.hpp:6321
constexpr bool is_errored() const
Definition: json.hpp:6394
bool key(string_t &val)
Definition: json.hpp:6339
json_sax_dom_parser(json_sax_dom_parser &&)=default
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6265
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:6309
bool end_array()
Definition: json.hpp:6371
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
Definition: json.hpp:6274
typename BasicJsonType::string_t string_t
Definition: json.hpp:6266
bool number_integer(number_integer_t val)
Definition: json.hpp:6297
Definition: json.hpp:6858
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
Definition: json.hpp:6885
token_type
token types for the parser
Definition: json.hpp:6862
@ value_float
an floating point number – use get_number_float() for actual value
@ begin_array
the character for array begin [
@ value_string
a string – use get_string() for actual value
@ end_array
the character for array end ]
@ uninitialized
indicating the scanner is uninitialized
@ parse_error
indicating a parse error
@ value_integer
a signed integer – use get_number_integer() for actual value
@ value_separator
the value separator ,
@ end_object
the character for object end }
@ literal_true
the true literal
@ begin_object
the character for object begin {
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
@ literal_null
the null literal
@ end_of_input
indicating the end of the input buffer
@ name_separator
the name separator :
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
@ literal_false
the false literal
lexical analysis
Definition: json.hpp:6935
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
Definition: json.hpp:8253
token_type scan()
Definition: json.hpp:8331
void skip_whitespace()
Definition: json.hpp:8323
lexer & operator=(lexer &&)=default
bool skip_bom()
skip the UTF-8 byte order mark
Definition: json.hpp:8309
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
Definition: json.hpp:6946
constexpr position_t get_position() const noexcept
return position of last read token
Definition: json.hpp:8263
constexpr number_integer_t get_number_integer() const noexcept
return integer value
Definition: json.hpp:8235
typename lexer_base< BasicJsonType >::token_type token_type
Definition: json.hpp:6944
lexer & operator=(lexer &)=delete
lexer(const lexer &)=delete
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
Definition: json.hpp:8241
constexpr number_float_t get_number_float() const noexcept
return floating-point value
Definition: json.hpp:8247
std::string get_token_string() const
Definition: json.hpp:8271
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
Definition: json.hpp:8296
exception indicating other library errors
Definition: json.hpp:4134
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4137
exception indicating access out of the defined range
Definition: json.hpp:4117
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4120
Definition: json.hpp:14179
output_adapter(std::basic_ostream< CharType > &s)
Definition: json.hpp:14186
output_adapter(std::vector< CharType, AllocatorType > &vec)
Definition: json.hpp:14182
output_adapter(StringType &s)
Definition: json.hpp:14190
output adapter for output streams
Definition: json.hpp:14131
void write_character(CharType c) override
Definition: json.hpp:14137
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
Definition: json.hpp:14133
output adapter for basic_string
Definition: json.hpp:14156
void write_character(CharType c) override
Definition: json.hpp:14162
output_string_adapter(StringType &s) noexcept
Definition: json.hpp:14158
output adapter for byte vectors
Definition: json.hpp:14106
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
Definition: json.hpp:14108
void write_character(CharType c) override
Definition: json.hpp:14112
exception indicating a parse error
Definition: json.hpp:4029
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
Definition: json.hpp:4041
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4049
const std::size_t byte
byte index of the parse error
Definition: json.hpp:4066
syntax analysis
Definition: json.hpp:11603
bool sax_parse(SAX *sax, const bool strict=true)
Definition: json.hpp:11703
parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
Definition: json.hpp:11613
bool accept(const bool strict=true)
public accept interface
Definition: json.hpp:11695
void parse(const bool strict, BasicJsonType &result)
public parser interface
Definition: json.hpp:11635
Definition: json.hpp:12077
primitive_iterator_t operator+(difference_type n) noexcept
Definition: json.hpp:12127
primitive_iterator_t & operator++() noexcept
Definition: json.hpp:12139
constexpr bool is_end() const noexcept
return whether the iterator is at end
Definition: json.hpp:12112
primitive_iterator_t & operator-=(difference_type n) noexcept
Definition: json.hpp:12171
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition: json.hpp:12106
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:12122
primitive_iterator_t operator++(int) &noexcept
Definition: json.hpp:12145
void set_begin() noexcept
set iterator to a defined beginning
Definition: json.hpp:12094
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:12117
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:12134
primitive_iterator_t & operator--() noexcept
Definition: json.hpp:12152
void set_end() noexcept
set iterator to a defined past the end
Definition: json.hpp:12100
constexpr difference_type get_value() const noexcept
Definition: json.hpp:12088
primitive_iterator_t operator--(int) &noexcept
Definition: json.hpp:12158
primitive_iterator_t & operator+=(difference_type n) noexcept
Definition: json.hpp:12165
Definition: json.hpp:17183
const error_handler_t error_handler
error_handler how to react on decoding errors
Definition: json.hpp:18115
const std::lconv * loc
the locale
Definition: json.hpp:18100
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
Definition: json.hpp:18097
serializer(serializer &&)=delete
serializer & operator=(serializer &&)=delete
const char decimal_point
the locale's decimal point character
Definition: json.hpp:18104
std::uint8_t state
Definition: json.hpp:17525
std::size_t bytes
Definition: json.hpp:17526
const char thousands_sep
the locale's thousand separator character
Definition: json.hpp:18102
serializer & operator=(const serializer &)=delete
std::size_t undumped_chars
Definition: json.hpp:17530
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
Definition: json.hpp:17238
const char indent_char
the indentation character
Definition: json.hpp:18110
std::size_t bytes_after_last_accept
Definition: json.hpp:17529
std::array< char, 512 > string_buffer
string buffer
Definition: json.hpp:18107
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
Definition: json.hpp:17523
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
Definition: json.hpp:17198
serializer(const serializer &)=delete
string_t indent_string
the indentation string
Definition: json.hpp:18112
exception indicating executing a member function with a wrong type
Definition: json.hpp:4100
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4103
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
Definition: json.hpp:13110
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
Definition: json.hpp:13194
void pop_back()
remove last reference token
Definition: json.hpp:13222
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
Definition: json.hpp:13201
json_pointer parent_pointer() const
returns the parent of this JSON pointer
Definition: json.hpp:13208
bool empty() const noexcept
return whether pointer points to the root document
Definition: json.hpp:13260
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
Definition: json.hpp:13179
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:13246
typename string_t_helper< RefStringType >::type string_t
Definition: json.hpp:13132
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
Definition: json.hpp:13161
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
Definition: json.hpp:13186
friend class json_pointer
Definition: json.hpp:13116
string_t to_string() const
return a string representation of the JSON pointer
Definition: json.hpp:13142
friend bool operator==(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
compares two JSON pointers for equality
Definition: json.hpp:13950
const string_t & back() const
return last reference token
Definition: json.hpp:13234
friend bool operator!=(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
compares two JSON pointers for inequality
Definition: json.hpp:13957
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
Definition: json.hpp:13171
json_pointer(const string_t &s="")
create JSON pointer
Definition: json.hpp:13136
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:13253
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
Definition: json.hpp:4886
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
Definition: json.hpp:2453
#define JSON_HEDLEY_CONST
Definition: json.hpp:1609
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
Definition: json.hpp:893
#define JSON_INLINE_VARIABLE
Definition: json.hpp:2356
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition: json.hpp:1239
#define JSON_PRIVATE_UNLESS_TESTED
Definition: json.hpp:2416
#define NLOHMANN_JSON_VERSION_PATCH
Definition: json.hpp:52
#define JSON_HEDLEY_LIKELY(expr)
Definition: json.hpp:1504
#define JSON_HEDLEY_NON_NULL(...)
Definition: json.hpp:1397
#define JSON_INTERNAL_CATCH(exception)
Definition: json.hpp:2383
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition: json.hpp:1838
#define JSON_CATCH(exception)
Definition: json.hpp:2382
#define JSON_ASSERT(x)
Definition: json.hpp:2409
#define JSON_THROW(exception)
Definition: json.hpp:2380
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
Definition: json.hpp:2684
#define NLOHMANN_JSON_VERSION_MAJOR
Definition: json.hpp:50
#define NLOHMANN_BASIC_JSON_TPL
Definition: json.hpp:2462
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1505
#define JSON_TRY
Definition: json.hpp:2381
#define JSON_NO_UNIQUE_ADDRESS
Definition: json.hpp:2362
#define NLOHMANN_JSON_VERSION_MINOR
Definition: json.hpp:51
#define JSON_HEDLEY_DIAGNOSTIC_POP
Definition: json.hpp:894
#define JSON_EXPLICIT
Definition: json.hpp:2674
#define JSON_HEDLEY_PURE
Definition: json.hpp:1578
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
Definition: json.hpp:21818
void init()
Definition: main.cpp:120
int map[20][10][20]
Definition: main.cpp:63
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
Definition: json.hpp:16858
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
Definition: json.hpp:17010
Target reinterpret_bits(const Source source)
Definition: json.hpp:16078
boundaries compute_boundaries(FloatType value)
Definition: json.hpp:16219
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
Definition: json.hpp:16522
constexpr int kGamma
Definition: json.hpp:16342
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
Definition: json.hpp:16576
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
Definition: json.hpp:16958
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
Definition: json.hpp:16617
constexpr int kAlpha
Definition: json.hpp:16341
cached_power get_cached_power_for_binary_exponent(int e)
Definition: json.hpp:16358
detail namespace with internal helper functions
Definition: json.hpp:2167
typename std::enable_if< B, T >::type enable_if_t
Definition: json.hpp:2919
typename T::reference reference_t
Definition: json.hpp:3282
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
Definition: json.hpp:3845
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition: json.hpp:2753
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition: json.hpp:3367
typename T::key_compare detect_key_compare
Definition: json.hpp:3351
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition: json.hpp:3291
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
Definition: json.hpp:3842
void to_json(BasicJsonType &j, T b) noexcept
Definition: json.hpp:5157
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
Definition: json.hpp:3463
value_t
the JSON type enumeration
Definition: json.hpp:2724
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
Definition: json.hpp:4193
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition: json.hpp:3023
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
Definition: json.hpp:8521
typename T::pointer pointer_t
Definition: json.hpp:3279
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
Definition: json.hpp:8494
is_detected< string_can_append, StringType, Arg > detect_string_can_append
Definition: json.hpp:3830
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition: json.hpp:11594
typename std::conditional< is_key_type_comparable< BasicJsonType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, typename BasicJsonType::object_t::key_type >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, typename BasicJsonType::object_comparator_t >::value) &&!is_json_iterator_of< BasicJsonType, KeyType >::value &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
Definition: json.hpp:3727
typename T::difference_type difference_type_t
Definition: json.hpp:3276
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition: json.hpp:2216
void int_to_string(string_type &target, std::size_t value)
Definition: json.hpp:4687
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
Definition: json.hpp:4347
integer_sequence< size_t, Ints... > index_sequence
Definition: json.hpp:2961
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
Definition: json.hpp:8506
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
Definition: json.hpp:8478
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
Definition: json.hpp:3833
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
Definition: json.hpp:8498
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
Definition: json.hpp:8482
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
Definition: json.hpp:17095
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition: json.hpp:5280
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
Definition: json.hpp:3460
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition: json.hpp:2229
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition: json.hpp:2905
cbor_tag_handler_t
how to treat CBOR tags
Definition: json.hpp:8624
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
parse_event_t
Definition: json.hpp:11577
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
error_handler_t
how to treat decoding errors
Definition: json.hpp:17175
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
Definition: json.hpp:8502
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition: json.hpp:5989
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
Definition: json.hpp:3739
typename T::key_type key_type_t
Definition: json.hpp:3270
std::size_t combine(std::size_t seed, std::size_t h) noexcept
Definition: json.hpp:5488
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: json.hpp:5506
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition: json.hpp:2834
typename utility_internal::Gen< T, N >::type make_integer_sequence
Definition: json.hpp:3007
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
Definition: json.hpp:8486
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition: json.hpp:2225
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition: json.hpp:2222
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
Definition: json.hpp:8513
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
Definition: json.hpp:4536
void concat_into(OutStringType &)
Definition: json.hpp:3823
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition: json.hpp:4207
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
Definition: json.hpp:2814
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition: json.hpp:2210
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
Definition: json.hpp:3848
typename make_void< Ts... >::type void_t
Definition: json.hpp:2172
OutStringType concat(Args &&... args)
Definition: json.hpp:3907
make_integer_sequence< size_t, N > make_index_sequence
Definition: json.hpp:3015
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
Definition: json.hpp:14101
typename T::mapped_type mapped_type_t
Definition: json.hpp:3267
input_format_t
the supported input formats
Definition: json.hpp:5643
void to_json(BasicJsonType &j, const T &b)
Definition: json.hpp:5274
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
Definition: json.hpp:3827
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
Definition: json.hpp:4530
decltype(std::declval< T >().template get< U >()) get_template_function
Definition: json.hpp:3294
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
Definition: json.hpp:3730
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
Definition: json.hpp:4430
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
Definition: json.hpp:3839
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
Definition: json.hpp:6046
typename T::is_transparent detect_is_transparent
Definition: json.hpp:3707
decltype(std::declval< T & >().null()) null_function_t
Definition: json.hpp:8474
typename is_comparable< typename BasicJsonType::object_comparator_t, const key_type_t< typename BasicJsonType::object_t > &, KeyType >::type is_key_type_comparable
Definition: json.hpp:3704
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:4850
typename T::iterator_category iterator_category_t
Definition: json.hpp:3285
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
Definition: json.hpp:8490
std::size_t concat_length()
Definition: json.hpp:3792
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
Definition: json.hpp:3836
decltype(std::declval< T & >().end_array()) end_array_function_t
Definition: json.hpp:8516
void from_json(const BasicJsonType &j, std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > &m)
Definition: json.hpp:4595
decltype(std::declval< T & >().end_object()) end_object_function_t
Definition: json.hpp:8509
T conditional_static_cast(U value)
Definition: json.hpp:3761
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition: json.hpp:3288
typename T::value_type value_type_t
Definition: json.hpp:3273
namespace for Niels Lohmann
Definition: json.hpp:2165
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.hpp:23364
NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin)
bool operator!=(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
Definition: json.hpp:13957
bool operator==(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
Definition: json.hpp:13950
Definition: json.hpp:4870
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.hpp:23414
void begin(GLenum shape)
Definition: tigl.cpp:133
void end()
Definition: tigl.cpp:143
default JSONSerializer template argument
Definition: json.hpp:5335
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
Definition: json.hpp:5339
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
Definition: json.hpp:5349
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
Definition: json.hpp:5359
Definition: json.hpp:3359
typename BasicJsonType::default_object_comparator_t object_comparator_t
Definition: json.hpp:3361
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
Definition: json.hpp:3363
typename BasicJsonType::object_t object_t
Definition: json.hpp:3360
Definition: json.hpp:3375
Definition: json.hpp:3374
Op< Args... > type
Definition: json.hpp:2206
std::true_type value_t
Definition: json.hpp:2205
Definition: json.hpp:2197
Default type
Definition: json.hpp:2199
std::false_type value_t
Definition: json.hpp:2198
Definition: json.hpp:16206
diyfp plus
Definition: json.hpp:16209
diyfp w
Definition: json.hpp:16207
diyfp minus
Definition: json.hpp:16208
Definition: json.hpp:16345
std::uint64_t f
Definition: json.hpp:16346
int k
Definition: json.hpp:16348
int e
Definition: json.hpp:16347
Definition: json.hpp:16088
static constexpr int kPrecision
Definition: json.hpp:16089
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
Definition: json.hpp:16177
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
Definition: json.hpp:16194
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
Definition: json.hpp:16112
constexpr diyfp(std::uint64_t f_, int e_) noexcept
Definition: json.hpp:16094
int e
Definition: json.hpp:16092
std::uint64_t f
Definition: json.hpp:16091
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
Definition: json.hpp:16100
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition: json.hpp:5069
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
Definition: json.hpp:5098
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition: json.hpp:5082
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition: json.hpp:5057
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition: json.hpp:5047
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
Definition: json.hpp:4986
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
Definition: json.hpp:4995
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
Definition: json.hpp:4940
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
Definition: json.hpp:5008
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
Definition: json.hpp:5034
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
Definition: json.hpp:5021
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition: json.hpp:5127
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition: json.hpp:5117
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition: json.hpp:5138
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
Definition: json.hpp:4962
static void construct(BasicJsonType &j, const CompatibleStringType &str)
Definition: json.hpp:4973
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
Definition: json.hpp:4953
Definition: json.hpp:4934
Definition: json.hpp:4625
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
Definition: json.hpp:4627
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3313
Definition: json.hpp:3298
Definition: json.hpp:3354
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3328
Definition: json.hpp:3323
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3343
Definition: json.hpp:3338
Definition: json.hpp:4163
Definition: json.hpp:2947
T value_type
Definition: json.hpp:2948
static constexpr std::size_t size() noexcept
Definition: json.hpp:2949
an iterator value
Definition: json.hpp:12192
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:12198
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:12196
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:12194
Definition: json.hpp:3247
Definition: json.hpp:3234
Definition: json.hpp:3691
Definition: json.hpp:3555
Definition: json.hpp:3574
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition: json.hpp:3633
std::numeric_limits< RealIntegerType > RealLimits
Definition: json.hpp:3632
Definition: json.hpp:3622
Definition: json.hpp:3645
typename BasicJsonType::object_t object_t
Definition: json.hpp:3485
Definition: json.hpp:3477
Definition: json.hpp:3497
Definition: json.hpp:3534
static constexpr auto value
Definition: json.hpp:3535
Definition: json.hpp:3648
Definition: json.hpp:3661
Definition: json.hpp:3470
nlohmann::detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value) &&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
Definition: json.hpp:3604
Definition: json.hpp:3577
Definition: json.hpp:3618
typename BasicJsonType::object_t object_t
Definition: json.hpp:3509
Definition: json.hpp:3501
Definition: json.hpp:3530
Definition: json.hpp:3541
static constexpr auto value
Definition: json.hpp:3549
ConstructibleStringType laundered_type
Definition: json.hpp:3546
Definition: json.hpp:3664
Definition: json.hpp:3407
Definition: json.hpp:3387
Definition: json.hpp:2213
Definition: json.hpp:3306
static constexpr bool value
Definition: json.hpp:3307
Definition: json.hpp:5965
typename std::iterator_traits< T >::value_type value_type
Definition: json.hpp:5966
Definition: json.hpp:3423
Definition: json.hpp:3670
Definition: json.hpp:3257
Definition: json.hpp:3749
char x[2]
Definition: json.hpp:3750
Definition: json.hpp:3745
@ value
Definition: json.hpp:3756
char one
Definition: json.hpp:3746
static one test(decltype(&C::capacity))
Definition: json.hpp:3442
static constexpr bool value
Definition: json.hpp:3456
Definition: json.hpp:8556
Definition: json.hpp:8525
static constexpr bool value
Definition: json.hpp:8538
Definition: json.hpp:3681
T & reference
Definition: json.hpp:3111
T * pointer
Definition: json.hpp:3110
T value_type
Definition: json.hpp:3108
std::random_access_iterator_tag iterator_category
Definition: json.hpp:3107
ptrdiff_t difference_type
Definition: json.hpp:3109
Definition: json.hpp:3095
typename It::difference_type difference_type
Definition: json.hpp:3084
typename It::reference reference
Definition: json.hpp:3087
typename It::iterator_category iterator_category
Definition: json.hpp:3088
typename It::pointer pointer
Definition: json.hpp:3086
typename It::value_type value_type
Definition: json.hpp:3085
Definition: json.hpp:3076
Definition: json.hpp:2169
void type
Definition: json.hpp:2170
Definition: json.hpp:3381
Definition: json.hpp:2183
nonesuch(nonesuch const &)=delete
void operator=(nonesuch &&)=delete
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch const &)=delete
abstract output adapter interface
Definition: json.hpp:14087
virtual void write_characters(const CharType *s, std::size_t length)=0
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
virtual ~output_adapter_protocol()=default
output_adapter_protocol(const output_adapter_protocol &)=default
output_adapter_protocol()=default
struct to capture the start position of the current token
Definition: json.hpp:2869
std::size_t lines_read
the number of lines read
Definition: json.hpp:2875
std::size_t chars_read_current_line
the number of characters read in the current line
Definition: json.hpp:2873
std::size_t chars_read_total
the total number of characters read
Definition: json.hpp:2871
Definition: json.hpp:3031
Definition: json.hpp:3030
Definition: json.hpp:3036
static constexpr T value
Definition: json.hpp:3037
Definition: json.hpp:5300
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
Definition: json.hpp:5302
Definition: json.hpp:2967
Definition: json.hpp:2986
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
Definition: json.hpp:2988
SAX interface.
Definition: json.hpp:6130
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool null()=0
a null value was read
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6131
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6135
virtual bool end_array()=0
the end of an array was read
virtual bool key(string_t &val)=0
an object key was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6132
virtual bool binary(binary_t &val)=0
a binary value was read
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6133
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
json_sax(json_sax &&) noexcept=default
virtual bool boolean(bool val)=0
a boolean value was read
json_sax(const json_sax &)=default
virtual bool end_object()=0
the end of an object was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
typename BasicJsonType::string_t string_t
Definition: json.hpp:6134
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
a minimal map-like container that preserves insertion order
Definition: json.hpp:18147
T & at(const Key &key)
Definition: json.hpp:18194
std::vector< std::pair< const Key, T >, Allocator > Container
Definition: json.hpp:18150
T mapped_type
Definition: json.hpp:18149
const T & at(const Key &key) const
Definition: json.hpp:18207
iterator find(const Key &key)
Definition: json.hpp:18304
iterator erase(iterator pos)
Definition: json.hpp:18239
void insert(InputIt first, InputIt last)
Definition: json.hpp:18351
std::pair< iterator, bool > insert(value_type &&value)
Definition: json.hpp:18328
const_iterator find(const Key &key) const
Definition: json.hpp:18316
Key key_type
Definition: json.hpp:18148
size_type erase(const Key &key)
Definition: json.hpp:18220
T & operator[](const Key &key)
Definition: json.hpp:18184
iterator erase(iterator first, iterator last)
Definition: json.hpp:18244
typename Container::const_iterator const_iterator
Definition: json.hpp:18152
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
Definition: json.hpp:18348
ordered_map(It first, It last, const Allocator &alloc=Allocator())
Definition: json.hpp:18166
std::equal_to< Key > key_compare
Definition: json.hpp:18158
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
Definition: json.hpp:18164
std::pair< iterator, bool > insert(const value_type &value)
Definition: json.hpp:18333
typename Container::size_type size_type
Definition: json.hpp:18153
typename Container::value_type value_type
Definition: json.hpp:18154
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
Definition: json.hpp:18168
ordered_map() noexcept(noexcept(Container()))
Definition: json.hpp:18163
size_type count(const Key &key) const
Definition: json.hpp:18292
typename Container::iterator iterator
Definition: json.hpp:18151
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
Definition: json.hpp:18171
const T & operator[](const Key &key) const
Definition: json.hpp:18189
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
Definition: json.hpp:23383
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition: json.hpp:23397